Finish entering text (type()) before finding image

Asked by Willie

What I am trying to do is enter in some text with the type() function, and then press an enter button.

What happens when I do this is the text gets about half way done being typed and then the script moves on to finding the button... Anyone else notice this?

I've tried hovering over the button instead of clicking it to see what happens and it will hover when about half the text has been typed and then it continues to type the rest.

Any way to wait for all the text to be typed before executing the next command? Bug? Thoughts?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

when type() does not work correctly (might contain "bad" characters, see faq 933), it is always a good idea to try paste() instead.

paste("some text")
type(Key.ENTER)

Revision history for this message
RaiMan (raimund-hocke) said :
#2

when type() does not work correctly (might contain "bad" characters, see faq 933), it is always a good idea to try paste() instead.

paste("some text")
type(Key.ENTER)

Revision history for this message
Willie (willie-owens91) said :
#3

Ok I'll try that tomorrow, but I'm not sure if I can use a Ctrl+V shortcut in this application. I'm using a US QWERTY keyboard though and just typing a few letters and a string of numbers

Revision history for this message
Calle Rundgren (c-rundgren) said :
#4

I think that paste() kicks type() butt every single day. There should be no problems using paste() instead of type(). De facto paste() is much faster and works like a charm.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#5

@ Calle
But Willie might be right: since paste() internally simply simulates a ctrl-v, there might be situations, where simulating key strokes (what type() does) is the only chance, since a ctrl-v might not be accepted by the GUI.

@Willie
So it is not a "bad" character problem.
Then it might be that type() fires too fast.

instead of:
txt = "some text\n"
type(txt)

try:
for c in txt:
    type(c)
    wait(t)

and try with different t values (starting with 0.1)

Revision history for this message
Willie (willie-owens91) said :
#6

Thanks RaiMan, that solved my question.