I followed this code taken from Eneroth Viewport Resizer and modified.
if RUBY_VERSION < "2.0.0"
require File.join(PLUGIN_ROOT, "ene_viewport_resizer", "Win32API.so")
else
require "Win32API"
end;
GetActiveWindow = Win32API.new("user32.dll", "GetActiveWindow", "", "L") unless defined?GetActiveWindow
GetWindowRect = Win32API.new("user32.dll", "GetWindowRect", "LP", "I") unless defined?GetWindowRect
ShowWindow = Win32API.new("user32.dll", "ShowWindow", "LI", "I") unless defined?ShowWindow
MoveWindow = Win32API.new("user32.dll", "MoveWindow", "LIIIII", "I") unless defined?MoveWindow
GetAncestor = Win32API.new("user32.dll", "GetAncestor", "LI", "I") unless defined?GetAncestor
GA_ROOTOWNER = 3 unless defined?GA_ROOTOWNER
SW_RESTORE = 9 unless defined?SW_RESTORE
@hwnd = GetActiveWindow.call; # remember Scatchup root window
def self.get_hwnd
return @hwnd
end;
puts "ERROR hwnd UNDEFINED " if self.get_hwnd == 0
#Returns array of left, top, right and bottom
def self.get_rect(hwnd)
rect = [0, 0, 0, 0].pack("L*")
GetWindowRect.call hwnd, rect
rect.unpack("L*").map { |e| [e].pack("L").unpack("l").first }
end;
#Get window size as array of width and height.
def self.get_size(hwnd)
left, top, right, bottom = self.get_rect hwnd
puts "left: #{left}, top: #{top}, right: #{right}, bottom: #{bottom}"
w = right - left
h = bottom - top
return [w, h]
end;:
I have problems with the self.get_rect(hwnd) method. It returns odd numbers.
I show you what I have on screen.
Can you help to correct it?
Height of the window is around 600 or higher. Width is cca 542.
The call window_size = self.get_size @hwnd should return correct size.