random text writing and making sikuli wait

Asked by winarto

hey everyone that matters, im using sikuli and i think its a marvelous software!!

i am not programmer but very interested to learn more and it appears that i am stuck with 3 issues, been trying to solve for weeks..

1. how to make sikuli write in text box? need to click in the text box and then start writing

2. how to make the writing random but with certain pattern, lets say:

andrew1
andrew90
andrew95

i want the andrew stay the same but the numbers vary from 1-100

3. how to make sikuli wait for an image to appear indefinetely until it appear? it only wait for like 3-5 seconds and then the script fail. my country got lousy internet connection so there always problem with the waiting time...

thanks a bunch to you who answer my questions, u guys doing great work!!

Question information

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

Since I am RaiMan I always ask:
did you already read through the docs?
http://doc.sikuli.org

some of your questions are basics, that are answered there.

*** how to make sikuli wait for an image
wait(img, time_value_seconds) # FOREVER for unlimited wait

or instaed of
click(image)
use
click(wait(image, 20))

the given time value in seconds is a maximum wait time for this individual image search.

You might also use
setAutoWaitTimeout(seconds)

which sets the standard waiting time for all subsequent searches on the screen.
(Be aware: region specific)

*** i want the andrew stay the same but the numbers vary from 1-100
import random
num = randint(1, 100) # each call gives random number
user = "andrew"+str(num)
print user

*** how to make sikuli write in text box?
you have to use an image near the text field and in IDE Preview (click on image thumbnail) set the target offset, so the click point is inside the text field.
click(image_with_target_offset) # positions caret in field
type("a", KeyModifier.CTRL) # select current content (optional)
type(Key.BACKSPACE) # delete content (optional)
type(user) # types the current content of variable user

hope it helps and raises fun with Sikuli

Revision history for this message
winarto (winarto-poernomo) said :
#2

i've read the guide just now but still confused, i'm sorry for being kinda dumb but many difficult words...

i've tried #1 and it workd great!!
#2 havent try and #3 can you give the sample? lets say i want to write ALBERT, how to write the script? i get the point where you say click on image but inserting the text im confused..

sorry again for being so newb in this thing, appreciate all the help

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

--- putting #2 and #3 together
import random
num = randint(1, 100) # each call gives random number
user = "ALBERT"+str(num)
print "Name =", user
# now user contains "ALBERTNN" where NN is between 1 and 100
# e.g. ALBERT55

# now we make the input field ready
# you have to use an image near the text field and in IDE Preview (click on image thumbnail)
# set the target offset, so the click point is inside the text field.
click(image_with_target_offset) # positions caret in field

# now we use type(), to type in the text contained in user
type(user)

the additional type()'s are only for the case, that you want to empty the field before typing new stuff.

type("a", KeyModifier.CTRL) # select current content (optional)
type(Key.BACKSPACE) # delete content (optional)

*** script without comments (supposing field is empty)
import random
num = randint(1, 100)
user = "ALBERT"+str(num)
print "Name =", user
click(image_with_target_offset)
type(user)

Revision history for this message
winarto (winarto-poernomo) said :
#4

thanks for the reply, ive just returned from abroad with no internet, will try ASAP and let u know, thanks a bunch!!!

Can you help with this problem?

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

To post a message you must log in.