Jump to content
Sign in to follow this  
jodyflorian

Absolute position of GuiControl?

Recommended Posts

jodyflorian

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

Share this post


Link to post
Share on other sites
trancexx

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

_WinAPI_GetSystemMetrics() will give you that information.

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Authenticity

_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.

Share this post


Link to post
Share on other sites
monoceres

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

:lmao:


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
jodyflorian

Fantastic - thanks I think it's working!

Share this post


Link to post
Share on other sites
PsaltyDS

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

:lmao:

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)

:think:


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

Share this post


Link to post
Share on other sites
monoceres

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.. :lmao:

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×