← 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

    Status: Answered => Solved

Johnnyninja confirmed that the question is solved:
I finally got it working. Much more to add to the script but this is a
good base to start from. I hope this helps someone else.

Adding the double backslash fixed my filename problem. One of our
developers helped me out with cleaning up the script. Some action was
not needed.

import os
dir = "D:\\Documents and Settings\\joma\\Desktop\\files"

# this line was added along with the if else statement because I get an extra pop up after the first 3D file is #created. You have an option to either add to the current 3D space or open a new one.
first = 1
for e in os.listdir(dir): # this starts the loop
    fileName = os.path.join(dir, e)
    print fileName
    # at this point you might be positioned on an input field for the filename
    type('o', KeyModifier.CTRL)
    paste(fileName)
    type(Key.ENTER)
    wait (2)
    # wait for the file to be opened
    click(".png")
    wait (2)
    if first:
        first = 0
    else:
        click("New3D.png")
        click("OK-1.png")
        wait (2)
    click(".png") 
    wait(5)

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