Docfxit Posted July 4, 2017 Posted July 4, 2017 I'd like to understand why the result of WinGetPos is not reliable. It seems to change for no reason I can figure out. If Not WinActive("UltraEdit Setup", "Install >>") Then WinActivate("UltraEdit Setup", "Install >>") WinWaitActive("UltraEdit Setup", "Install >>") Local $aPos = WinGetPos("UltraEdit Setup") ;get The Pos ConsoleWrite(IsArray($aPos) & @CRLF) ;~For Debugging Only If IsArray($aPos) Then Local $iX = $aPos[0] Local $iY = $aPos[1] + ($aPos[3] / 2) Local $aPixel = PixelSearch($iX, $iY, $iX + 100, $iY + 100, 0x606060, 1, 1) ConsoleWrite(IsArray($aPixel) & @CRLF) ;~For Debugging Only If IsArray($aPixel) Then MouseMove($aPixel[0] + 5, $aPixel[1] + 5) ;Just for debug MouseClick("left", $aPixel[0] + 5, $aPixel[1] + 5, 1, 0) Sleep(1000) ;just wait some miliseconds Sometimes the mouse is where it should be and sometimes it's way far away from the window it should be working with. Thanks, Docfxit
Docfxit Posted July 4, 2017 Author Posted July 4, 2017 That fixed it. It's now reliable. I don't understand on the line: ConsoleWrite(IsArray($aPixel) & @CRLF) ;~For Debugging Only When it gets written to the Console it's always 1 When I run it in the AutoIt Debugger it writes out: $aPos(0) 673 $aPos(1) 381 $aPos(2) 574 $aPos(3) 318 Thank you very much, Docfxit
Xandy Posted July 4, 2017 Posted July 4, 2017 (edited) Also opt("PixelCoordMode", 0..2) PixelCoordMode Sets the way coords are used in the pixel functions, either absolute coords or coords relative to the window defined by hwnd (default active window): 0 = relative coords to the defined window 1 = (default) absolute screen coordinates 2 = relative coords to the client area of the defined window Oops sry. I didn't know was solved xD Edited July 4, 2017 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker)
Docfxit Posted July 4, 2017 Author Posted July 4, 2017 1 minute ago, Xandy said: Also opt("PixelCoordMode", 0..2) PixelCoordMode Sets the way coords are used in the pixel functions, either absolute coords or coords relative to the window defined by hwnd (default active window): 0 = relative coords to the defined window 1 = (default) absolute screen coordinates 2 = relative coords to the client area of the defined window Although it's working for the moment. I'll add this to make sure it's reliable. Thank you, Docfxit
Docfxit Posted July 4, 2017 Author Posted July 4, 2017 I don't understand on the line: ConsoleWrite(IsArray($aPixel) & @CRLF) ;~For Debugging Only When it gets written to the Console it's always 1 When I run it in the AutoIt Debugger it writes out: $aPos(0) 673 $aPos(1) 381 $aPos(2) 574 $aPos(3) 318 Thank you very much, Docfxit
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