Jump to content
Sign in to follow this  
JohnOne

Bogus results from standard UDF

Recommended Posts

JohnOne

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
AdmiralAlkex

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
squid808

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
JohnOne

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.