# drag and drop from mouse current location to center of screen

Asked by arminius on 2017-06-30

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:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
arminius
Solved:
2017-07-04
Last query:
2017-07-04
Last reply:
2017-07-03
 masuo (masuo-ohara) said on 2017-06-30: #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

 arminius (arminius75) said on 2017-06-30: #2

yes, I marked them as solved.

 masuo (masuo-ohara) said on 2017-06-30: #3

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

 arminius (arminius75) said on 2017-07-02: #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.

 Manfred Hampl (m-hampl) said on 2017-07-03: #5

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))

 arminius (arminius75) said on 2017-07-04: #6

That worked great, thanks.

To post a message you must log in.