Jump to content
Sign in to follow this  
Kalagaraz

ControlGetPos()

Recommended Posts

Kalagaraz

I'm trying to get the position of a control at runtime but ControlGetPos() doesn't seem to return an accurate Y value. It doesn't matter what position the control is at, it always returns 0 for the y value. X value works fine.

Doing this because I need to have the mouse click and drag in a accurate spot on the control no matter where the control is.

Since there is no ControlClickDrag I have to use MouseClickDrag when takes screen coordinates. So I came up with doing:

$x = ControlPos[0] + $controlCoordinateX

$y = ControlPos[1] + $controlCoordinateY

Here is the code I was using for testing

$controlPos = controlGetPos($windowTitle,"", $controlID)
$x = $controlPos[0]
$y = $controlPos[1]
MsgBox(4096, "coordinates x", $x)
MsgBox(4096, "coordinates y", $y)

As I said earlier, it returns the X coordinate correctly (verified with window info tool) however the Y coordinate is always 0 (even though the window info tool shows another number)

Share this post


Link to post
Share on other sites
Kalagaraz

Looks like ControlGetPos() is working fine in AutoIt 3.2.4.9

If Not ProcessExists('calc.exe') Then
    Run('calc.exe')
EndIf
WinWait('Calculator')
$pos = ControlGetPos('Calculator', '', 'Button24')
If Not @error Then
    MsgBox(0, '', 'X = ' & $pos[0] & ' Y = ' & $pos[1])
EndIf

:rolleyes:

Same version I have, maybe it's not working because it's a flash control?

My controlID: $controlID = "[CLASS:MozillaWindowClass; INSTANCE:5]"

It can't be my code since it's working perfectly for X it's just Y thats messed up.

Edited by Kalagaraz

Share this post


Link to post
Share on other sites
Kalagaraz

Oh duh nevermind. It's the controls position relative to the window, not the screen.

That's pretty confused since the WindowInfo tool gives the position based on screen, yet the function gives it based on window?

Share this post


Link to post
Share on other sites
herewasplato

...the WindowInfo tool gives the position based on screen...

See here:

http://www.autoitscript.com/forum/index.php?showtopic=46724

For other coordinates

AutoIt v3 Window Info > Options > Coord Mode > .....

should change things.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
MHz

Nope, doesn't matter what it's set on, it still displays the controls position relative to the screen.

Yes, your right. It gives position relative to screen only. This may need to be reported as a bug.

:rolleyes:

Share this post


Link to post
Share on other sites
herewasplato

Nope, doesn't matter what it's set on, it still displays the controls position relative to the screen.

The link that I posted is a bug report on that very issue...

...then I said, "For other coordinates..."

:-(


[size="1"][font="Arial"].[u].[/u][/font][/size]

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  

×