Jump to content

Recommended Posts

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.

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
Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...