Search the Community
Showing results for tags 'mousecoordmode'.
-
Is there a way to programmatically determine the state of MouseCoordMode in AutoIt? I've got a function that is called that must have Opt("MouseCoordMode", 1) 1=absolute, however when I'm done I'd like to return the MouseCoordMode to what the calling program was using so I don't mess it up. Yes, I know I've written the program, however different functions within the program use different values for MouseCoordMode and rather than using some Global to keep track I'm wondering if I can determine the state of MouseCoordMode programmatically. Thanks for any hints.
-
Something simple enough, and I am sure it's an oversight, but I have not been able to track this down. The entire script is attached, but here is the point of failure. Note: I am getting the "Error: subscript used on non-accessible variable" but I thought the initial line of: AutoItSetOption('MouseCoordMode', 0) Should address that issue? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Install updates (minimized and updating for many minutes) ; Updates Not Installed Screen ; Wait for updates to complete WinWait("ProSeries Update") ; Wait just over 9 minutes to ensure popup is ready (test alternative to WinWait) Sleep(550000) ; Set focus on Product Licenses window WinActivate("ProSeries Update") ; Send Mouse Click to Install Now button MouseClick ( "left" [, 581, 362 [, clicks = 1 [, speed = 10]]] ) ; end Installing Updates screen >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Thanks for any insights! c1one ProSeries2017_No_Customer_Info.au3
- 8 replies
-
- mouseclick
- autoitsetoption
-
(and 1 more)
Tagged with:
-
Hi, I am trying to create an automation script that will realistically mimic a users input suitable for recording in a repeatable manner. I am able to use the MouseMove command to hover an icon on the desktop, double click it, and open the software. I searched these forums for a reliable way to use MouseMove to move to a control on the new window and found this article: I have modified the code to look like this so I can see the movement of the mouse: Func _ControlMouseClick($iTitle, $iText, $iControl, $iButton = "left", $iClicks = "1", $iSpeed = "30", $iXpos = "", $iYpos = "") $iOriginal = Opt("MouseCoordMode") ;Get the current MouseCoordMode Opt("MouseCoordMode",2) ;Change the MouseCoordMode to relative coords $aPos = ControlGetPos($iTitle, $iText, $iControl) ;Get the position of the given control ConsoleWrite("Control position: " & $aPos[0] & "x" & $aPos[1]) MouseMove($aPos[0] + ($aPos[2]/2) + $iXpos, $aPos[1] + ($aPos[3]/2) + $iYpos, $iSpeed) $mPos = MouseGetPos() ConsoleWrite("Cursor position: " & $mPos[0] & "x" & $mPos[1]) MouseClick($iButton, Default, Default, $iClicks, $iSpeed) ;Move the mouse and click on the given control Opt("MouseCoordMode",$iOriginal) ;Change the MouseCoordMode back to the original EndFunc ;==>_ControlMouseClick Now, when I try to call this function using the following code: _ControlMouseClick($installerTitle, "", "[CLASS:Button; INSTANCE:2]") I get the following written to the console: And the mouse has not visibly moved across the screen at all. It is still hovering the icon on the desktop. Here is the full code I have: ; #FUNCTION# ==================================================================================================================== ; Name...........: _ControlMouseClick ; Description ...: Use the mouse to move to a control and click it ; Syntax.........: _ControlMouseClick($iTitle, $iText, $iControl [, $iButton = "left" [, $iClicks = "1" [, $iSpeed = "10" [, $iXpos = "" [, $iYpos = "" ]]]]] ) ; Parameters ....: $iTitle - The title of the window containing the control ; $iText - Some text from the window containing the control. Can enter no text be using "" ; $iControl - The Control ID of the control to click ; $iButton - [optional] The button to click: "left", "right", "middle", "main", "menu", "primary", "secondary". Default is "left" ; $iClicks - [optional] The number of times to click the mouse. Default is 1. ; $iSpeed - [optional] The speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10. ; $iXpos - [optional] The x position to click within the control. Default is center. ; $iYpos - [optional] The y position to click within the control. Default is center. ; Author ........: Kris Mills <fett8802 at gmail dot com> ; UserCallTip....: _ControlMouseClick ( "title", "text", controlID [, button [, clicks [, speed [, x [, y ]]]]] ) Use the mouse to move to a control and click it.(required: #include <KrisUDF.au3>) ; =============================================================================================================================== Func _ControlMouseClick($iTitle, $iText, $iControl, $iButton = "left", $iClicks = "1", $iSpeed = "30", $iXpos = "", $iYpos = "") $iOriginal = Opt("MouseCoordMode") ;Get the current MouseCoordMode Opt("MouseCoordMode",2) ;Change the MouseCoordMode to relative coords $aPos = ControlGetPos($iTitle, $iText, $iControl) ;Get the position of the given control ConsoleWrite("Control position: " & $aPos[0] & "x" & $aPos[1]) MouseMove($aPos[0] + ($aPos[2]/2) + $iXpos, $aPos[1] + ($aPos[3]/2) + $iYpos, $iSpeed) $mPos = MouseGetPos() ConsoleWrite("Cursor position: " & $mPos[0] & "x" & $mPos[1]) MouseClick($iButton, Default, Default, $iClicks, $iSpeed) ;Move the mouse and click on the given control Opt("MouseCoordMode",$iOriginal) ;Change the MouseCoordMode back to the original EndFunc ;==>_ControlMouseClick MouseMove(110, 110, 30) MouseClick("", Default, Default, 2) $installerTitle = "Setup" WinWait($installerTitle) WinActivate($installerTitle) _ControlMouseClick($installerTitle, "", "[CLASS:Button; INSTANCE:2]") Any thoughts on getting this to work so that the cursor moves smoothly over the control I am specifying?