← Back to team overview

sikuli-driver team mailing list archive

[Question #689767]: addHotKey cannot coerce 3rd argument to HotkeyListener

 

New question #689767 on Sikuli:
https://answers.launchpad.net/sikuli/+question/689767

I am using this version of the IDE: 2.0.4-2020-03-14_08:01/Windows10.0/Java8(64)1.8.0_241-b07

When I use the following program in the Sikuli IDE, it works as expected, and I can break out of the program by typing Ctrl-Shft-F:

running = True
def quitApp(event):
    print "handler quit ctrl-shft-f"
    global running
    running = False

Env.addHotkey('f', KeyModifier.CTRL + KeyModifier.SHIFT, quitApp)

while running:
    print "hello"
    sleep(1)


So far so good. Then I try to run the exact same program from Jython command line (with Sikulixapi-2.0.4.jar on the CLASSPATH), with an additional line to import the Sikuli scripts:

from org.sikuli.script import *

running = True
def quitApp(event):
    print "handler quit ctrl-shft-f"
    global running
    running = False


Env.addHotkey('f', KeyModifier.CTRL + KeyModifier.SHIFT, quitApp)

while running:
    print "hello"
    sleep(1)


However, when I run this, I get the following error:

Traceback (most recent call last):
  File "temp.py", line 10, in <module>
    Env.addHotkey('f', KeyModifier.CTRL + KeyModifier.SHIFT, quitApp)
TypeError: addHotkey(): 3rd arg can't be coerced to org.sikuli.basics.HotkeyListener

Any idea what might be causing the problem?

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.