Jump to content

ControlGetPos()


Recommended Posts

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)

Link to comment
Share on other sites

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

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:

Link to comment
Share on other sites

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]

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