← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #222218]: how to open windows folder in explore directly?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Depending on what you want to do with your files:
There are tons of modules and functions in Python (as in every scripting language), to work with files directly,without fiddling around with rightClick()'s in an explorer window. With Sikuli, this approach is always to be preferred.

dir = os.path.join('c:', os.sep, 'tssmoketest', tsVersion)
for name in os.listdir(dir): # all files in dir
     print name # the bare name of the file
     print os.path.join(dir, name) # the filename with path

most things you can do in the context menu for a file in explorer you
can do with Python directly in your script.

But if you really need the explorer window, you need to use the Windows
start command, so the os.popen comes back directly to continue your
script. the rest is string handling, to setup the correct command for
os.popen().

the start command, to open an explorer window:
dir = os.path.join('c:', os.sep, 'tssmoketest', tsVersion)
os.popen('start explorer "%s" ' % dir)

this works even if the path name contains blanks.

if you are sure, your path does not contain blanks (only ASCII characters, numbers, underscores and hyphens):
os.popen("start explorer " + dir)

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