Reputation: 25
Is there a way to ask the user to click on a Location and save the coordinates to use that Location later?
None of the tools isted in the page https://sikulix-2014.readthedocs.io/en/latest/interaction.html are suitable for the job, i think.
Upvotes: 0
Views: 95
Reputation: 126
This is RaiMan from SikuliX
Eugene's answer is absolutely correct: Currently SikuliX does not have any features to get feedback, when a user clicks somewhere on the screen.
But for your request there is a rather simple solution:
simg = userCapture("select location (center of capture)") # capture with prompt
loc = None # None means user did not capture (ESC)
if simg != None:
loc = simg.getRegion().getCenter() # the location to use as center of capture
print loc
This will tell the user to capture a region, that has its center at the wanted location. The internal capture result (ScreenImage) knows its coordinates on the screen.
Hope it helps ;-)
Upvotes: 2
Reputation: 6910
There are two parts to your question.
The first item seems to be irrelevant for Sikuli. You will have to use some other tools to do that. Regarding the second question, the answer is:
To get current mouse location (not click):
getmouseLoc = Env.getMouseLocation()
x = getmouseLoc.getX()
y = getmouseLoc.getY()
Upvotes: 1