Docfxit

WinGetPos explanation

6 posts in this topic

#1 ·  Posted

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

Share this post


Link to post
Share on other sites



#2 ·  Posted

Could be related to the MouseCoordMode option?

Share this post


Link to post
Share on other sites

#3 ·  Posted

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Xandy

Share this post


Link to post
Share on other sites

#5 ·  Posted

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

Share this post


Link to post
Share on other sites

#6 ·  Posted

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

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