sikulisikuli-scriptsikuli-x

App open opening multiple window in sikuli


Hello guys I loved this sikuli but I found one issue related to app.open as well as app.focus

Here is my code my code has single line to test wheater app.open or focus open single instance

  App.open("C:\\program file\internet explorer\\iexplore.exe")
  Or 
  App.focus("C:\\program file\internet explorer\\iexplore.exe")

Both app.open and app.focus open explorer multiple time for eg:- suppose not any explorer open on first app.open or focus it open explorer now re run code the it again open explorer i.e now I have explorer instance

Expected to check if multiple explorer instance is open then close all and open single instance and if single open then just focus it is there any other alternative


Solution

  • Try this code below. I got this to work. So, basically, we are checking if the app window exists and if it does, close it. Else, it will ofcourse break from the loop.

    Check the below link for the exact explanation on how window command works:

    https://sikulix-2014.readthedocs.io/en/latest/appclass.html#window

    myApp = App("Notepad.exe")
    while(myApp.window() is not None):
        myApp.close()
        myApp = App("Notepad.exe")