Jump to content

Move the mouse cursor in the center of a window


ffdshow
 Share

Recommended Posts

Sorry i posted this in AutoIt v2 Help and support.

I need a script to move the cursor in the center of a window (to open then the contextual menu).

I know how to perform right click in a (x,y) coordinates but I need to do this automatically in the center of a window.

The script can automatically get the coordinates, width and height of window and input this in MouseClick function?

How can I use WinGetPos and MouseClick together?

Link to comment
Share on other sites

Sorry i posted this in AutoIt v2 Help and support.

I need a script to move the cursor in the center of a window (to open then the contextual menu).

I know how to perform right click in a (x,y) coordinates but I need to do this automatically in the center of a window.

The script can automatically get the coordinates, width and height of window and input this in MouseClick function?

How can I use WinGetPos and MouseClick together?

Opt("MouseCoordMode", 2)      ;1=absolute, 0=relative, 2=client
Run('mspaint.exe')
Local $winTitle = 'untitled - Paint'
WinWait($winTitle)
Local $posArray = WinGetPos($winTitle)
If @error Then
    MsgBox(0,'you suck','')
    Exit
EndIf
Local $xCenter =  ($posArray[2]/2)
Local $yCenter =  ($posArray[3]/2)
MouseMove($xCenter,$yCenter);OR MouseClick('left',$xCenter,$yCenter)

MouseCoordMode set to client is my suggestion then you can just use WinGetPos and divide the width and height and move the mouse or click the mouse there. That's my suggestion.

Edited by JohnBailey
A decision is a powerful thing
Link to comment
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
 Share

  • Recently Browsing   0 members

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