RaiMan / SikuliX-2014

SikuliX version 1.1.2 (until February 2018)
http://sikulix.com
805 stars 235 forks source link

Opening app with context on windows #264

Open dariuskrs opened 7 years ago

dariuskrs commented 7 years ago

Let's say I want to open an app on windows, but I want it to be executed in another context path. I know how to call the app:

openApp("C:\Program Files (x86)\MyApp\Launcher\launcher.exe")

But how can I tell it to run in a specific context, like say C:\Program Files (x86)\MyApp\Execution context?

Also, how can I know when the app has loaded (the 'wait' solution does not seem reliable)? regards.

glitchassassin commented 7 years ago

Try using os.chdir() to set the current directory before calling the executable. Haven't tested it, but I think that should work.

If you use the App class to create your app, you can wait until it creates a window:

a = App.open("C:\Program Files (x86)\MyApp\Launcher\launcher.exe")
while not a.hasWindow():
    sleep(1)

Note that it's a good idea to add a timeout in case the app doesn't launch - otherwise it'll wait forever.