drag and drop from mouse current location to center of screen

Asked by arminius

I have code that drags and drops from a location to the center of the screen.
"x1 = 300
y1 = 300
x2 = 640
y2 = 512
dragDrop(Location(x1,y1),Location(x2,y2))"

is it possible to go from the mouses current location to the center of the screen.

"x1 = mouses current position
y1 = mouses current postion
x2 = 640
y2 = 512
dragDrop(Location(x1,y1),Location(x2,y2))"

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
arminius
Solved:
Last query:
Last reply:
Revision history for this message
masuo (masuo-ohara) said :
#1

There are similar questions that you asked.
Are there not solved yet?
https://answers.launchpad.net/sikuli/+question/643830
https://answers.launchpad.net/sikuli/+question/643686

Revision history for this message
arminius (arminius75) said :
#2

yes, I marked them as solved.

Revision history for this message
masuo (masuo-ohara) said :
#3

So it is possible to go from the mouses current location to the center of the screen.

Revision history for this message
arminius (arminius75) said :
#4

I need to be able to have it done on the fly though.
something like this "hover(Pattern("185693845869.png").targetOffset(29,29))
x1 = ml.getX()
y1 = ml.getY()
x2 = 640
y2 = 512
dragDrop(Location(x1,y1),Location(x2,y2))"

That throws "[error] NameError ( name 'ml' is not defined )" though.

Revision history for this message
Manfred Hampl (m-hampl) said :
#5

in https://answers.launchpad.net/sikuli/+question/643830 you had

ml = Env.getMouseLocation()
print ml
print ml.getX()
print ml.getY()

If you now omit the first line of that block, you will of course get an error "name 'ml' is not defined"

Try
dragDrop(Env.getMouseLocation(),Location(640,512))

Revision history for this message
arminius (arminius75) said :
#6

That worked great, thanks.