Jump to content

Absolute position of GuiControl?


Recommended Posts

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

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

Link to comment
Share on other sites

_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

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!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...