View Single Post
  #2 (permalink)  
Old 03-31-2009, 12:56 PM
SWFKit SWFKit is offline
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

In fact there aren't any methods in swfkit can get the screen coordinates of a window. Fortunately, it can be done by calling windows api directly. A little complicated, but it works.

Code:
var wnd = getMainWnd();
var l = wnd.clientRect.left;
var t = wnd.clientRect.top;
var r = l + wnd.clientRect.width;
var b = t + wnd.clientRect.height;

trace(l, ',', t, ',', r, ',', b);

struct { 
  long x; 
  long y; 
} POINT;

dllimport "user32.dll" stdcall Boolean ClientToScreen(int, POINT*);
var v = new Object;
v.value = new Struct(POINT);

v.value.x = l;
v.value.y = t;
ClientToScreen(wnd.handle, v);
l = v.value.x;
t = v.value.y;

v.value.x = r;
v.value.y = b;
ClientToScreen(wnd.handle, v);
r = v.value.x;
b = v.value.y;

trace(l, ',', t, ',', r, ',', b);

var img = Image.captureScreen(l, t, r - l, b - t);
img.save('e:\\temp\\test.jpg');
Reply With Quote