sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #22268
Re: [Question #223258]: How get (x, y) cursor location of mouse click?
Question #223258 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/223258
jptlse proposed the following answer:
What do you think about import java-api ? Code below show mouse location with a red circle around cursor location.
SHIFT + ESC to exit from running script.
#----------------------------------------------------------------------------------------------------
# Get jar from here : https://code.google.com/p/sikuli-api/downloads/list
#----------------------------------------------------------------------------------------------------
assert load('/Users/jp/git/git-jtools/sikulihook/lib/sikuli-api-1.0.2-standalone.jar')
import sys
import org.sikuli.api.visual.DesktopCanvas as DesktopCanvas;
import org.sikuli.api.DesktopScreenRegion as DesktopScreenRegion;
import java.awt.Color as Color;
class MouseLocation():
def __init__(self):
self.status=True
Env.addHotkey(Key.ESC, KeyModifier.SHIFT, self.stopLoopHnd)
while self.status:
self.showMousePosition()
def stopLoopHnd(self, event):
self.status=False
def showMousePosition(self):
mouseLoc = Env.getMouseLocation()
strCursorPos = "X:" + str(mouseLoc.getX()) + ", Y:" + str(mouseLoc.getY())
dsr = DesktopScreenRegion(20, 20, 100, 100)
dc = DesktopCanvas()
dc.addLabel(dsr, strCursorPos).withFontSize(30).withColor(Color.BLUE)
dc.addCircle(DesktopScreenRegion(mouseLoc.getX(), mouseLoc.getY(), 1, 1).getRelativeScreenLocation(0, 0)).display(1)
if __name__ == '__main__':
MouseLocation()
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.