Sequential Vs POP UP

Asked by winarto

Dear Admins,

i am using sikuli to run an application , shortly what i want to ask is this application require both seqential and loop.

SEQUENTIAL means there are lets say 100 steps need to be clicked sequentially
POP UP means that sometimes there is a pop up like network disconnected (my internet is not stable)

this problems causing my sequential script that i have made to be broken. FYI i use a very simple one because i AM NOT a programmer and learning sikuli by myself along with my busy office hour. here's an example of my script

click(wait("1363921523078-3.png",FOREVER))
if exists("Ewagon-3.png", FOREVER):
    click("1363921560439-3.png")
    wait(0)
hover(wait("1363925846640-1.png",FOREVER))

those 3 (click, if exists, hover ) are by far my best exploration on the feature of your fabulous application. problem is when the script is running and the 'network disconnected' pop up it ruin my whole script , lets say that the script command is click(...picture A...) and then disrupted by the pop up the script wont move since there is no picture A shown..

how to solve this? i have been browsing http://doc.sikuli.org/genindex.html but most guides are either too difficult or not answering my question (i thought).

a solution of this that im thinking about is to run 2 script at the same time, lets say 1 script is SEQUENTIAL and 1 script is LOOPING, but is this possible and how? please give me simple solution as i am not a programmer.

thanks alot raiman (this guy always answer me) or any other admin in advance

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

Your idea is principally ok:

Settings.MoveMouseDelay=0
while True:
    if exists(popupimage, 0):
        click(okbutton)
    wait(1)

If you run this script from command line using Sikuli-IDE-w.bat, it will do what you want.
Be aware: this script must be killed with the TaskManager to stop it.

But this might not prevent your first script from crashing in all cases, because the 2 scripts will not coordinate the usage of mouse and keyboard.
This is the situation (might have a low probability): your main script found an image and before it can click, the popup comes up. If the popup now hides the click point, the click will happen, but with no effect in the sense of your script. So now though the poup will be handled, the next action of your script will fail.

Another case is, that the clickpoint is still visible outside the popup, and the popup handler uses the mouse in the same time, that the main script is in a click process. To reduce this risk, use the Settings.MoveMouseDelay=0 in your main script too - this will switch off the mouse move animation, which simply is some delay between finding and clicking.
If you could handle the popup without using the mouse (e.g. with a type(Key.ENTER)), this will solve the mouse problem generally.

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

owkay so now the question is how do i run 2 scripts at the same time? by opening 2 sikuli?

so first sikuli is to kill the pop up and i press PLAY
second sikuli which is the main script then i also press PLAY

is this even possible? and i tried to kill off sikuli using task manager before (without shift+alt+c) and sikuli doesnt appear in task manager?

thanks

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

- you start your main script in the IDE

- you start the "kill-popup" script somehow (might be possible to use a second IDE, I would prefer using the command line version Sikuli-IDE-w.bat, in which case the taskmanager shows a process javaw)

Revision history for this message
j (j-the-k) said :
#4

You could also use the observer()-method to observe the screen.

def closePopup():
    click(okbutton)

onAppear(popupimage, closePopup)
observe(FOREVER, True)

This will start the observation of the screen and click the okbutton everytime the popupimage is found.
As the observer will start a new thread, you will not have to use two different scripts.

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

sorry but im still confused.. let me elaborate more of my condition..

1. i use sikuli-ide.bat to run sikuli
2. the main script is somewhat like this:
def wpyckipwltlll(n):
    type("blablablabla%d"%(n))
    if exists("gmail-1.png", FOREVER):
        click("1364355012633.png")
        wait(0)
    type("blah")
    hover(wait("SlgnUp-1.png",FOREVER))
    hover(wait("SlgnUp-1.png",FOREVER))
    hover(wait("SlgnUp-1.png",FOREVER))
    hover(wait("SlgnUp-1.png",FOREVER))
    click(wait("SlgnUp-1.png",FOREVER))
    hover(wait("SavePlay.png",FOREVER))
    hover(wait("SavePlay.png",FOREVER))
blablablabla(1)
blablablabla(2)
blablablabla(3)

the problem is sometimes in between there are 1-2 TYPES of pop ups and it is occasionally, lets say between

    hover(wait("SlgnUp-1.png",FOREVER))
    click(wait("SlgnUp-1.png",FOREVER))

sometimes there are pop ups.

so from my understanding to solve this (info from u guys):
1. run another sikuli (to shut down need to use task manager, cant use ctrl+shift+c)
2. observer method (im very confused, can you give me example on its application with my script above?

many thanks

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

to keep open

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.