ffdshow Posted September 13, 2007 Posted September 13, 2007 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?
James Posted September 13, 2007 Posted September 13, 2007 $Width = @DesktopWidth $Height = @DesktopHeight MouseMove($Width, $Height, 0) Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
JohnBailey Posted September 13, 2007 Posted September 13, 2007 (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 September 13, 2007 by JohnBailey A decision is a powerful thing
ofLight Posted September 13, 2007 Posted September 13, 2007 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
JohnBailey Posted September 13, 2007 Posted September 13, 2007 Sleep(2000) $WinLoc = WinGetPos("") MouseMove($WinLoc[0]+($WinLoc[2]/2),$WinLoc[1]+($WinLoc[3]/2),20) better idea A decision is a powerful thing
ffdshow Posted September 13, 2007 Author Posted September 13, 2007 (edited) The last is the best method posted here. Thanks to all! Edited September 13, 2007 by ffdshow
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now