← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #179709]: How to open any application from user defined path

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
This works on my Win7:

Needed to run successfully:
a folder c:\Tests containing 4 files test1.txt, test2.txt, test3.txt, test4.txt

What it does:
for ear of the above files a Notepad process is started and the process ids are stored in the sequence as the processes where started.
In the end pids contains the process ids in this order.
the last loop is to demonstrate, that the pids are in correct sequence

Hope it helps, to get a little bit further.

import os
s = Env.getOSUtil()
for i in range(4):
    os.popen(r'start /D "c:\Tests" notepad test'+str(i+1)+".txt")
    cmd = r'tasklist /FI "IMAGENAME eq notepad.exe" /FO csv /NH'
    ps = os.popen(cmd).readlines()
    pids = []
    for p in ps:
        #print p
        pid = int(eval("("+p+")")[1])
        print "ProcessID:", pid
        if not pid in pids:
            pids.append(pid)
for p in pids:
    s.switchApp(p, 0)
    s.getWindow(p).highlight(2)

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