Jump to content

Using MouseMove() - (Moved)


Recommended Posts

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 by Melba23
Fixed my own error
Link to comment
Share on other sites

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 by Musashi

Musashi-C64.png

"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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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)

 

Musashi-C64.png

"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

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

  • Moderators

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

@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

 

Link to comment
Share on other sites

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

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 by cappy2112
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...