Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to work with Key and KeyModifier classes #7

Open
moosavimaleki opened this issue Jul 12, 2021 · 3 comments
Open

how to work with Key and KeyModifier classes #7

moosavimaleki opened this issue Jul 12, 2021 · 3 comments

Comments

@moosavimaleki
Copy link

moosavimaleki commented Jul 12, 2021

hi

i want to type ALT+A

my code is:

reg = Region()
reg.type("a", Key.ALT())

and i define Key class by add this code to sxclasses.py :

class Key(SXBase):
    SXClass = SXKey

that SXKey = SXPKG.script.Key

but after run :

Traceback (most recent call last):
  File "testSikulix4python.py", line 22, in <module>
    reg.type("a", Key.ALT())
AttributeError: type object 'Key' has no attribute 'ALT'

Tanks 🌹🙏🏻

@moosavimaleki
Copy link
Author

moosavimaleki commented Jul 13, 2021

and next problem!
how to use wait(target_path,timeout)
wait() implemented in java is wait(PSI target, double timeout)
how can i create PSI object?
in click() we use PFRML opject for passing target [ click(PFRML target) ] and PFRML accept filepath
but wait function use PSI object

sxregion.py:

    def wait(self, *args):
        if len(args) == 0:
            return self.instance.wait()
        return self.instance.wait(convertArgs(args))

error: [this exception]

"SikuliX: find, wait, exists: invalid parameter: ..."

Tanks 🌹🙏🏻

--------------------------------------------------------------------------
update:
my python wait function for alternative use:

def myWait(_path, timeout=60, sleepStep=1):
    startTime = time.time()
    leftTime = 0
    existsState = scr.exists(_path)
    while not existsState and leftTime < timeout:
        time.sleep(sleepStep)
        leftTime = time.time() - startTime
        existsState = scr.exists(_path)
    return existsState

@RaiMan
Copy link
Owner

RaiMan commented Jul 15, 2021

Sorry, but I cannot help you in the moment.

This project is currently paused completely. You have to find the solutions yourself.


reg.type("a", Key.ALT())

should be

reg.type("a", Key.ALT)


Already tried exists(pathString, timeout)

@zxcvbs
Copy link

zxcvbs commented Jul 21, 2021

Hi moos, about type
type("a", Key.ALT)
I couldn't figure why Key.alt doesn't work. But i tried this
reg.type("f", SXKey.ALT )
reg.type("f", "\ue022") #using unicode.
And it works great.
I found the remaining definitions on:
https://github.com/RaiMan/SikuliX1/blob/master/API/src/main/java/org/sikuli/hotkey/Keys.java

Rai i love Sikuli, this is great. I hope to learn more about it.

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

No branches or pull requests

3 participants