Sign in to follow this  
Followers 0
JohnOne

Bogus results from standard UDF

5 posts in this topic

#1 ·  Posted (edited)

I would expect the following code (modified from helpfile) to move the mouse to the bottom right of window client area.

#include <WinAPI.au3>

_Main()

Func _Main()
    Local $hwnd, $tRect
    Run("notepad.exe")
    $hwnd = WinWaitActive("Untitled - Notepad", "")
    If IsHWnd($hwnd) Then
        $tRect = _WinAPI_GetClientRect($hwnd)
        MsgBox(4096, "Rect", _
                "Left..: " & DllStructGetData($tRect, "Left") & @LF & _
                "Right.: " & DllStructGetData($tRect, "Right") & @LF & _
                "Top...: " & DllStructGetData($tRect, "Top") & @LF & _
                "Bottom: " & DllStructGetData($tRect, "Bottom"))
        MouseMove(DllStructGetData($tRect, "Right"), DllStructGetData($tRect, "Bottom"), 0)
    Else
        MsgBox(0, "", "")
    EndIf
EndFunc

Except is does not, am I forgetting something?

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Look at the numbers from the MsgBox, is the top-left really at 0,0? Not even close. It is intentional, see the function description at MSDN. Or in the helpfile for WinGetClientSize() (same thing obviously).

You have to figure out some other way to get the bottom right of client area.

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

Try adding opt("MouseCoordMode",2) to the top, seems to work for me after that.

Share this post


Link to post
Share on other sites

You forgot a line:

Opt("MouseCoordMode", 2) ; 2 = relative coords to the client area of the active window

:graduated:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks guys, I thought I must have been forgetting something.

#include <WinAPI.au3>

_Main()

Func _Main()
    Local $hwnd, $tRect, $tpoint
    Run("notepad.exe")
    $hwnd = WinWaitActive("Untitled - Notepad", "")
    If IsHWnd($hwnd) Then
        $tRect = _WinAPI_GetClientRect($hwnd)
        $tpoint = DllStructCreate("int X;int Y")
        DllStructSetData($tpoint, "X", DllStructGetData($tRect, "Left"))
        DllStructSetData($tpoint, "Y", DllStructGetData($tRect, "Top"))

        _WinAPI_ClientToScreen ($hwnd, $tpoint)

        MsgBox(0,"",DllStructGetData($tpoint, "X") &"x"&DllStructGetData($tpoint, "Y")&@LF)

        MouseMove(DllStructGetData($tpoint, "X"), DllStructGetData($tpoint, "Y"), 0)
    Else
        MsgBox(0, "", "")
    EndIf
EndFunc   ;==>_Main

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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  
Followers 0