Kalagaraz Posted June 13, 2007 Share Posted June 13, 2007 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 More sharing options...
MHz Posted June 13, 2007 Share Posted June 13, 2007 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 Link to comment Share on other sites More sharing options...
Kalagaraz Posted June 13, 2007 Author Share Posted June 13, 2007 (edited) 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 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 June 13, 2007 by Kalagaraz Link to comment Share on other sites More sharing options...
Kalagaraz Posted June 13, 2007 Author Share Posted June 13, 2007 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? Link to comment Share on other sites More sharing options...
herewasplato Posted June 13, 2007 Share Posted June 13, 2007 ...the WindowInfo tool gives the position based on screen...See here:http://www.autoitscript.com/forum/index.php?showtopic=46724For other coordinatesAutoIt v3 Window Info > Options > Coord Mode > .....should change things. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Kalagaraz Posted June 13, 2007 Author Share Posted June 13, 2007 See here:http://www.autoitscript.com/forum/index.php?showtopic=46724For other coordinatesAutoIt v3 Window Info > Options > Coord Mode > .....should change things.Nope, doesn't matter what it's set on, it still displays the controls position relative to the screen. Link to comment Share on other sites More sharing options...
MHz Posted June 13, 2007 Share Posted June 13, 2007 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. Link to comment Share on other sites More sharing options...
herewasplato Posted June 13, 2007 Share Posted June 13, 2007 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 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