Opening Applications & Files Using Sikuli

App.open()

Since Sikuli is a python interpreter, python modules can be used to open programs and files. Sikuli does come with a command that opens general programs such as the App.open command.

App.open(FILE PATH) would open the specified file path. Make sure to wrap the path with double quotes and if you include spaces, add single quotes around the double quotes like this: App.open(‘”FILE PATH”‘). When referencing a file or path, make sure to include double backslashes:

App.open(“FILE PATH\\app.exe”) or App.open(r”FILE PATH\app.exe”). The ‘r’ in front of the path converts the statement into a string.

App.focus()

Another useful command is App.focus. When you are running a sikuli script, you always want it to flip between applications or files. Using App.focus() will switch the main window so Sikuli can run the code on the correct application. App.focus() uses a PID identifier. This identifier or name can be found in the task manager.

App.focus(“excel”) would bring Microsoft excel to the front.

App.focus(“iexplore”) would bring Internet Explorer to the front. 

What if you have multiple instances of the same application open. App.focus also solves for this by allowing indexing. If you have multiple excel files open, Sikuli identifies them by indexes from 0 to # of files open.

App.focus(“excel”[,2]) would flip to the third excel file instance. 

App.close()

Similar to the App.open(), App.close() does the opposite. It works the same way by referencing the path.

 

 

 

 

Related Articles