Skip to content
This repository has been archived by the owner on Mar 14, 2018. It is now read-only.

Click with key modifiers not working in Python #302

Open
imperialguy opened this issue Jan 24, 2018 · 1 comment
Open

Click with key modifiers not working in Python #302

imperialguy opened this issue Jan 24, 2018 · 1 comment

Comments

@imperialguy
Copy link

imperialguy commented Jan 24, 2018

Versions: sikulix 1.1.1 and 1.1.2 (from nightly builds)
OS: Windows 7

If I type the following command in SikuliX IDE, it works perfectly fine:

click('sample.png', KEY_SHIFT)

It clicks on the target while holding the SHIFT key simultaneously.

If I do the same thing in python through jnius, the normal click works, but click with key modifiers doesn't work. None of the following three ways of using key modifiers works.

    from jnius import autoclass
    Key = autoclass('org.sikuli.script.Key')
    KeyModifier = autoclass('org.sikuli.script.KeyModifier')
    region.click('sample.png') # works perfectly
    region.click('sample.png', KeyModifier.KEY_SHIFT) # doesn't work
    region.click('sample.png', Key.SHIFT) # doesn't work
    region.click('sample.png', KeyModifier.SHIFT) # doesn't work

They all throw the same error message:
JavaException: No methods matching your arguments

Of course, this works perfectly fine without the key modifiers. Please help.

@RaiMan
Copy link
Owner

RaiMan commented Jan 24, 2018

as already answered to your direct mail:

sorry, but I have nothing to do with Pyjnius ;-)

I guess the problem is, that something like Key.SHIFT is a static constant and does not have an accessor function.

So autoclass does not implement the access.

region.click() as you use it has this signature:
click(String, Integer)

the shift-modifier according to the Java docs is an int 1.

so try:
click(image, 1)

To verify the values in the SikuliX IDE simply use
print KeyModifier.SHIFT

But you might as well use one of the more sophisticated reflection features of Pyjnius.

Hope it helps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants