Repeat this simple script

Asked by RedCrew

Hi,

I know it is probably simple but I don't get it.
I learn when I see it.
How do I repeat this :

doubleClick("1351808176532.png") //open notepadd on desktop
wait(2)
click("Q.png") // close notepadd

I have to put this ?

while True:
doubleClick("1351808176532.png") //open notepadd on desktop
wait(2)
click("Q.png") // close notepadd

thank you !

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
Brian Redmond (bredmond) said :
#1

The indenting is important in python, so each line you want included in the loop must be indented:
while True:
    doubleClick("1351808176532.png") //open notepadd on desktop
    wait(2)
    click("Q.png") // close notepadd

and yes, this will continue to loop until one of two things happens:
1) You manual cancel the script using the hotkey (Shift-Alt-c in Windows)
2) The click or doubleClick throw a FindFailed Exception

If you only wanted it to loop a certain number of times, you can use for with range. This would loop ten times:

for x in range(10):
    doubleClick("1351808176532.png") //open notepadd on desktop
    wait(2)
    click("Q.png") // close notepadd

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

faqs that might help additionally:
faq 1800 indentation
faq 1437 loops

Can you help with this problem?

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

To post a message you must log in.