← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #235186]: The implications of using type() vs. paste()

 

Question #235186 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/235186

    Status: Open => Answered

RaiMan proposed the following answer:
using type() is perfect as long as the used characters produce what you
want in the GUI and as long as included TAB (\t) and/or ENTER (\n)
and/or other Key.XXX work as expected.

There are 2 common problems:
1. in non US environments, many characters are not produced as expected, because type() only works correctly with US-qwerty keyboard layout.
2. the function keys are not accepted by the GUI, because type() sends the keys too fast.

at 1: the solution is to use paste() for the text parts and type() for
the function keys

at 2: normally it is sufficient, to insert some wait()s. For that you
have to split up the type().

Conclusion: All is ok, if it works. The above mentioned recommendation is for people new to Sikuli, that do not have any insight yet.
Looking at the questions and bugs: problems with type() came up very often since the beginning of Sikuli.

BTW: I will revise type() and  paste(), to accept this key notation as part of a string:
write(#T.dob#3T.2 Hay Street#T.#T3.Sydney#T.)

so Key.TAB will be #T. or #TAB. with the general form
#n1XXXn2.
n1 and n2 will be numbers 1 to 9 that result in a wait of nx*100msecs waiting before/after pressing the function key

... and there will be a repeat factor:
#3*3T5.
would be the same as:
wait(0.3)
type(Key.TAB)
wait(0.5)
type(Key.TAB)
wait(0.5)
type(Key.TAB)
wait(0.5)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.