cappy2112 Posted February 3, 2021 Share Posted February 3, 2021 (edited) Is MouseMove() supposed to move the Mouse pointer (the arrow) or the text cursor (the I beam) ? What units are the X & Y coordinates for the mouse ? When I run the following code (copied from the examples directory, and put into a loop) The mouse pointer just wiggles a very small amount. I can't seem to make it move from the right side of the screen to the left Local $loopCount = 0 Local $maxLoops = 10 While $loopCount < $maxLoops MouseMove(10, 100,0) ; Move the mouse cursor to the x, y position of 10, 100. Sleep(400) MouseMove(10000, 100, 0) ; Move the mouse cursor to the x, y position of 700, 700 and move instantly. $loopCount = $loopCount + 1 Sleep(400) WEnd Thanks Edited February 3, 2021 by Melba23 Fixed my own error Link to comment Share on other sites More sharing options...
Musashi Posted February 3, 2021 Share Posted February 3, 2021 (edited) 3 hours ago, cappy2112 said: The mouse pointer just wiggles a very small amount. No surprise, since you set two absolute mouse positions, and repeat this $maxLoops times. The coordiants are not changed within the loop. Check this example : Local $iMousePosX = 700, $iMousePosY = 700, $iMaxLoops = 500 MouseMove($iMousePosX, $iMousePosY, 0) For $iLoopCount = 1 To $iMaxLoops Step 10 MouseMove($iMousePosX-$iLoopCount, $iMousePosy, 2) Next MouseMove($iMousePosX, $iMousePosY, 0) For $iLoopCount = 1 To $iMaxLoops Step 10 MouseMove($iMousePosX-$iLoopCount, $iMousePosy-$iLoopCount, 2) Next Edited February 3, 2021 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 3, 2021 Moderators Share Posted February 3, 2021 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team cappy2112 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
junkew Posted February 3, 2021 Share Posted February 3, 2021 for $x =1 to @Desktopwidth for $y = 1 to @DesktopHeight mouseMove ( $x, $y , 0 ) Next Next cappy2112 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Musashi Posted February 3, 2021 Share Posted February 3, 2021 8 hours ago, cappy2112 said: I can't seem to make it move from the right side of the screen to the left Just out of curiosity : What is the reason for the loop? If you only want to move the mouse cursor from one point to another, then the following is sufficient: ; Variant 1 : set coordinates directly MouseMove(700,700, 0) ; starting position MouseMove(10,100, 50) ; speed set to 50 so you can see the effect ; Variant 2 : coordinates as array Local $aPoint1[2] = [700, 700] Local $aPoint2[2] = [10, 100] MouseMove($aPoint1[0], $aPoint1[1], 0) MouseMove($aPoint2[0], $aPoint2[1], 50) "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
cappy2112 Posted February 3, 2021 Author Share Posted February 3, 2021 11 hours ago, Musashi said: No surprise, since you set two absolute mouse positions, and repeat this $maxLoops times. The coordiants are not changed within the loop. Check this example : Local $iMousePosX = 700, $iMousePosY = 700, $iMaxLoops = 500 MouseMove($iMousePosX, $iMousePosY, 0) For $iLoopCount = 1 To $iMaxLoops Step 10 MouseMove($iMousePosX-$iLoopCount, $iMousePosy, 2) Next MouseMove($iMousePosX, $iMousePosY, 0) For $iLoopCount = 1 To $iMaxLoops Step 10 MouseMove($iMousePosX-$iLoopCount, $iMousePosy-$iLoopCount, 2) Next Do you not see the two calls to MouseMove() with different x coordinates? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 3, 2021 Moderators Share Posted February 3, 2021 Your code, as is, does not make my mouse just "wiggle", it moves from right to left horizontally, then returns to starting point and moves right to left diagonally. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
junkew Posted February 3, 2021 Share Posted February 3, 2021 @cappy2112 you are not clear on your question. To me it looks your mouse position is way off unless you really have a huge screen this works for me as you should calculate your location based on desktopwidth and desktopheight Local $loopCount = 0 Local $maxLoops = 4 consolewrite(@Desktopwidth & @CRLF) consolewrite(@DesktopHeight & @CRLF) While $loopCount < $maxLoops MouseMove(10, 100,0) ; Move the mouse cursor to the x, y position of 10, 100. Sleep(400) MouseMove(@Desktopwidth-100, 100, 0) ; Move the mouse cursor to the x, y position of 700, 700 and move instantly. $loopCount = $loopCount + 1 Sleep(400) WEnd cappy2112 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
cappy2112 Posted February 3, 2021 Author Share Posted February 3, 2021 5 hours ago, Musashi said: Just out of curiosity : What is the reason for the loop? If you only want to move the mouse cursor from one point to another, then the following is sufficient: ; Variant 1 : set coordinates directly MouseMove(700,700, 0) ; starting position MouseMove(10,100, 50) ; speed set to 50 so you can see the effect ; Variant 2 : coordinates as array Local $aPoint1[2] = [700, 700] Local $aPoint2[2] = [10, 100] MouseMove($aPoint1[0], $aPoint1[1], 0) MouseMove($aPoint2[0], $aPoint2[1], 50) So that I can see the movement. I know the coordinate unites are very small (in pixels ??), I wanted to verify that I could see some movement, so I repeated the same mousemove() call many times. Link to comment Share on other sites More sharing options...
cappy2112 Posted February 3, 2021 Author Share Posted February 3, 2021 (edited) 1 hour ago, JLogan3o13 said: Your code, as is, does not make my mouse just "wiggle", it moves from right to left horizontally, then returns to starting point and moves right to left diagonally. Well, I don't see anything move other than tht Mouse Arrow pointer, it's just pivoting left & right, but only a small amount. My monitors are 24 inches wide, so the desktop size is probably 1980 & 1600 (or close to that). Are video attachments allowed? Can I attach a small video from my phone to show you? Noone has answered my question- What is supposed to move? The mouse arrow pointer, or the I-Beam cursor? Edited February 3, 2021 by cappy2112 Link to comment Share on other sites More sharing options...
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