selection structure question

Asked by pipboy

Hi,thanks for all your previous help,
now this script almost complete
The "test.exe" will popup another Warning Windows when CPU usage over 90 %
then I tried hotkey "Alt+Shift+C" to interrupt loop but it does not work?

======================================================

  for i in range(n):
   openApp("C:\...\test.exe")

  if exists ( img [ Warning Window: Program Already Running] , 10) :
        click( img [Yes] ) #Continue loop
        wait(1)

  elif exists ( img [ Warning Window: Internal Error] ) :
       type("c", KEY_ALT+KEY_SHIFT) #Exit Script and stop count

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

you cannot type() to Sikuli, because it has not focus at that time (when running a script).

simply use exit().

elif exists ( img [ Warning Window: Internal Error] ) :
       exit() #Exit Script and stop count

Revision history for this message
pipboy (peace03) said :
#2

elif exists ( img [ Warning Window: Internal Error] ) :
       exit() #return the same results,script failed to stop

 is it possible image( Internal Error) display time too short?
led to sikuli cannot detect image( Internal Error) in time?
when loop is running, it will be covered (overlap) by image(Program Already Running)

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

If it is covered by the other popup, it cannot be found by Sikuli.

Sikuli works WYSIWYCS (What You See Is What You Can Search).

try another sequence:

 for i in range(n):

  if exists ( img [ Warning Window: Internal Error] ) :
     exit()) #Exit Script and stop count

  openApp("C:\...\test.exe")

  if exists ( img [ Warning Window: Program Already Running] , 10) :
        click( img [Yes] ) #Continue loop
        wait(1)

Revision history for this message
pipboy (peace03) said :
#4

Thanks RaiMan, that solved my question.