Issue with wait() and type()

Asked by sharon on 2018-02-23

We are trying out some python code using sikuli. We have a target, a notepad and we are trying to enter something in notepad with the below code.

    type("type this string")

So basically we need to press DOWN ARROW then type some string and then press ENTER and repeat. We have sikuli logs enabled.

Problem Part- While running, the key down, ENTER and typing strings are all logged in sikuli logs but the operation is not performed in notepad.

Without wait() or less wait time, say wait(0.5), its working as expected. It seems there is a problem while using wait() and type() together.

Anyone else face the same problem? Can anyone suggest a workaround?

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

what system, what SikuliX version?

sharon (sharoncep) said : #2

OS - Windows 7 - 32 bit
Sikuli Version - 1.1.1

RaiMan (raimund-hocke) said : #3

my test on Windows 10 / Java 8 (should not make a difference)
using a newly setup SikuliX 1.1.1

# wait(2)
wtime = 3

for i in range(5):
  type("some text")


worked with different wait times as it should.

BTW: starting the sequence with a DOWN does not really make sense (nothing to do with your problem though).

sharon (sharoncep) said : #4

Our actual application to be automated is NOT notepad.
This is just for the sample as we can not share the actual application.

It is working for us too for almost half a day. After that the it is hanging and not coming back to notepad for further actions.
In the debug log Type is displayed but actually text is not typed in notepad.

We tried after replacing Type with write method also. That too hung.
Also we noticed that it is hanging with wait(.5) too when tried again.

Our actual intention is to select a menu option from a drop down. Image comparison is failing here so we went for Key down and Enter using Type method.

sharon (sharoncep) said : #5

Any updates from anyone?

RaiMan (raimund-hocke) said : #6

Very hard to get behind the reason in such situations.
BTW: type() and write() internally are the same: using the features of Java Robot

If the type() is reported, but not actually done, then there are 2 possible reasons:
 - 1. the target app is blocking Java Robot actions (not the case here)
 - 2. the target app does not have focus in the way you expect it to have

Since SikuliX does not have a feature to check, wether the type was really done, the workflow must either secure beforehand, that the prerequisites for a definitive success are given (such as focus ready) or check afterwards with other means, that the type() was successful (if not, take corrective actions such as repeating the actions).

If in your case, the fallback solution (using arrow keys) works better: congratulations ;-) be happy.

Can you help with this problem?

Provide an answer of your own, or ask sharon for more information if necessary.

To post a message you must log in.