Sign in to follow this  
Followers 0
ffdshow

Move the mouse cursor in the center of a window

6 posts in this topic

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?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Sleep(2000)
$WinLoc = WinGetPos("")
MouseMove($WinLoc[0]+($WinLoc[2]/2),$WinLoc[1]+($WinLoc[3]/2),20)


There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Share this post


Link to post
Share on other sites

Sleep(2000)
$WinLoc = WinGetPos("")
MouseMove($WinLoc[0]+($WinLoc[2]/2),$WinLoc[1]+($WinLoc[3]/2),20)
better idea

A decision is a powerful thing

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

The last is the best method posted here.

Thanks to all!

Edited by ffdshow

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