sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #06629
Re: [Question #177654]: Stop a loop
Question #177654 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/177654
Status: Needs information => Answered
RaiMan proposed the following answer:
ok, thanks for the information.
Your problem has nothing to do with Python. You have some
misunderstanding about the capabilities of Sikuli script.
In Sikuli script, you script what you can see on the screen and nothing
else. Sikuli knows nothing about the app and in this case knows nothing
about the fact, that you are dealing with image files in a folder (which
is named test???). So Sikuli loops through the characters given by sour
string, which is 4 times in case of ".jpg" (has 4 characters).
If you want to loop through the images, you have to click until there is
something visible on the screen, that tells you, that no more files to
process are left in the folder.
So if it is not possible to "see" when the loop should end, you have to
get the counter from somewhere else.
Which is possible in this case:
What you can do in bash on the script level directly, is possible with Python too:
import os
dir = "absolute-path-to-your-imagefolder"
files = os.listdir(dir)
numfiles = 0
for f in files:
if not os.path.splitext(f)[1] in (".jpg", ".jpeg"): continue
numfiles += 1
numfiles now contains the number of files in the folder ending with .jpg or .jpeg. Now you can use numfiles to make your GUI loop:
for i in range(numfiles):
# your click code
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.