jodyflorian Posted January 25, 2009 Share Posted January 25, 2009 Hi, I've spent quite some time trying to find out how to make a script calculate or retrieve the absolute position of a Gui Control relative to the screen? I'm having problems because in calculating it I need to know what size border XP etc puts around windows - I can't seem to get round it? Thanks Jody Link to comment Share on other sites More sharing options...
trancexx Posted January 25, 2009 Share Posted January 25, 2009 Hi,I've spent quite some time trying to find out how to make a script calculate or retrieve the absolute position of a Gui Control relative to the screen?I'm having problems because in calculating it I need to know what size border XP etc puts around windows - I can't seem to get round it?ThanksJody_WinAPI_GetSystemMetrics() will give you that information. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Authenticity Posted January 25, 2009 Share Posted January 25, 2009 _WinAPI_GetWindowRect - Will give you the window dimensions relative to the upper left spot of the screen, you can then use _WinAP_GetSystemMetrics with $SM_CXBORDER for example to get the width of the border, you can get much more information from this function. There are a lot of helper functions, just take a look in the help file. Good-luck. Link to comment Share on other sites More sharing options...
monoceres Posted January 25, 2009 Share Posted January 25, 2009 Hi and welcome to the forums Once you realize controls and windows really are the same the solution is easy, just use WinGetPos(). Example: $hwnd=GUICreate("Test",120,70) $button=GUICtrlCreateButton("Test",10,10,100,50,0x2000) GUISetState() $buttonhwnd=WinGetHandle(ControlGetHandle($hwnd,"",$button)) Do $pos=WinGetPos($buttonhwnd) GUICtrlSetData($button,"X: "&$pos[0]&@CRLF&"Y: "&$pos[1]) Sleep(50) Until GUIGetMsg()=-3 Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
jodyflorian Posted January 25, 2009 Author Share Posted January 25, 2009 Fantastic - thanks I think it's working! Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 25, 2009 Share Posted January 25, 2009 Hi and welcome to the forums Once you realize controls and windows really are the same the solution is easy, just use WinGetPos(). Example: $hwnd=GUICreate("Test",120,70) $button=GUICtrlCreateButton("Test",10,10,100,50,0x2000) GUISetState() $buttonhwnd=WinGetHandle(ControlGetHandle($hwnd,"",$button)) Do $pos=WinGetPos($buttonhwnd) GUICtrlSetData($button,"X: "&$pos[0]&@CRLF&"Y: "&$pos[1]) Sleep(50) Until GUIGetMsg()=-3 I don't think you have to get the "handle of the handle" so just use: ; $buttonhwnd = WinGetHandle(ControlGetHandle($hwnd,"",$button)) $buttonhwnd = ControlGetHandle($hwnd,"",$button) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
monoceres Posted January 26, 2009 Share Posted January 26, 2009 I don't think you have to get the "handle of the handle" so just use: ; $buttonhwnd = WinGetHandle(ControlGetHandle($hwnd,"",$button)) $buttonhwnd = ControlGetHandle($hwnd,"",$button) Uhm yeah, that was stupid. I was tired.. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now