Simple mouse movement

Asked by Arca_Vorago

I have been trying to simulate simple mose movement actions, using something I found on here that uses get mouse location:

mLoc=Env.getMouseLocation().offset(300,300)
mouseMove(mLoc)
mouseMove(mLoc.offset(200,0))

but for some reason it doesn't always work, or sometimes will work once but then not repeat in the loop I have it in. Is there a simpler way to just move the mouse, say, on the y axis by 200 units? If I can figure that out my goal is to import math to have more advanced movements like circles/triangles, etc.

The question/answer I got it from is here: https://answers.launchpad.net/sikuli/+question/184255

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Arca_Vorago (4-ubuntuone-c) said :
#1

I also tried removing the original offset get to simplify things,

mLoc=Env.getMouseLocation()
mouseMove(mLoc)
mouseMove(mLoc.offset(200,0))

Revision history for this message
Best RaiMan (raimund-hocke) said :
#2

the easiest is this (supposing the mouse should be moved from the current location to a target:

1.0.1:
hover(env.getMouseLocation.right(200))

1.1.0:
hover(Mouse.at().right(200))

I just checked the API:

I will add a
mouseMove(xoff, yoff) that simply moves the mouse from the current location to the location given by the offset.
with that you might easily move the mouse along a prepared offset list or could be used in a function, that on the fly calculates the next point:

def moveCircle(radius):
   while True:
       # calculate next offset
       mouseMove(xoff, yoff)
       if finished: # check somehow, wether we are back at the beginning
           break

(will be available in the nightly build tomorrow)

Revision history for this message
RaiMan (raimund-hocke) said :
#3

added the feature

Revision history for this message
Arca_Vorago (4-ubuntuone-c) said :
#4

You are awesome RaiMan! Thank you very much, loving the good work, can wait till I learn sikuli a bit more in depth.

Revision history for this message
Arca_Vorago (4-ubuntuone-c) said :
#5

Thanks RaiMan, that solved my question.