← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #203363]: Best way to open and close all files in a directory one at a time?

 

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

RaiMan proposed the following answer:
ok, then you want to open all these files in the directory using your
cad application.

So I guess your first trial with one file, did some clicks and types on
the open cad application to bring up the file content in the app, do
something with it and the close the file again by clicking the
appropriate buttons in you app.

If this is true, then you simply have to do something like that:

import os
dir = "D:/Documents and Settings/user/Desktop/files"
# your cad app should be open and frontmost
for e in os.listdir(dir): # this starts the loop
    fileName = os.path.join(dir, e)
    print fileName
    # some operations on file the file by acting on the cad app
    click(png)
    click(png)
    # at this point you might be positioned on an input field for the filename
    paste(fileName)
    type(Key.ENTER)
    # wait for the file to be opened
    wait(5)
    # now do your stuff on the file
    # do your actions to close the file
    # here we go back to loop start to process the next file
print "all files processed" # this prints after the loop ends.

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