how to work with Key and KeyModifier classes
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 🌹🙏🏻
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
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)
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.