← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #217558]: I can agenerate random numbers, need to type them

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
This is what I mentioned in my first comment:
type() works if the input field has focus already.

This simply means (like you do that manually), that you have to activate Word somehow and then take care, that the caret is positioned and activated somewhere in Word, where you can type in something (usually the document).
In your case I suppose, that Word is already opened.

So if this is the intention of the doubleClick(), then you now have to check, what is wrong with it:
- it seams to find the image "SearchIEssVi.png", since it clicks
- by this click: is the desired input area selected and ready to accept keyboard input?

So you might try this, to clarify:

import random # only once at top of script

# doubleClick("SearchIEssVi.png")
# for debugging, we split this into:
m = find("SearchIEssVi.png") # finds the image
m.highlight(2) # red frame to show, what was found
doubleClick(m) # doubleClick it

wait(1) # we wait 1 second, to give time to the GUI

num = random.randrange(100000000, 100000000000000)
type(str(num))

wait(5) # wait 5 seconds to be able to see what happened on screen

The first wait can be reduced to a working minimum value, if it turns out, that it works with a wait.
The bloated doubleClick() can be reduced to one statement again, if it works.

*** I've never programmed or taken any classes, 
That is not really necessary, to get basic workflows running with Sikuli script.
But if you want to be happy with it for a longer time and increasing complexity, then you need some basic knowledge about Python scripting (see faq 1858).

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