// Obtain the position and size of the current window.
// Can be used to save the size and position that a user
//   might have changed for a window.

// Declare the Windows function for our use.
declare pfunc GetWindowRect returning integer in dll user.exe

set window type to 1+16+32+4096+8192
create window 'Test' from 2,2 to 20,50

wait

// Get the handle of the current window
hWnd = HWND()

// Create a variable that has the byte size of the RECT structure.
// 8 bytes since each point is an integer which is actually
// 2 bytes, and there are 4 points.
lprc = space(8)

// ALWAYS type cast the variables passed to a DLL function
// in the function call itself.  The 'lprc' does not have tp be type
// cast since we are passing the address of the variable by using
// the '@' symbol.
GetWindowRect(toint(hWnd), @lprc)

// Extract the individual POINTs of the structure.
// All coordinates are in pixels. UL: Upper Left, LR: Lower Right
// Left coordinate
iWndULY =  getint(@lprc,1)
// Top coordinate
iWndULX =  getint(@lprc,2)
// Right coordinate
iWndLRY =  getint(@lprc,3)
// Bottom coordinate
iWndLRX =  getint(@lprc,4)

close window 'Test'

set window type to 1+16+32+4096+8192

// Pixels must be subtracted to account for the title bar and the sizeable borders.
// If you use a different window type, the values will have to be changed.
create window 'Test' at point iWndULX-27,iWndULY to iWndLRX-70,iWndLRY-4

wait
