← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #145986]: Open the browser if it is active, or open a new window

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Hoping you are using the newest version X-1.0rc2, this is possible:

# preperations
ffLoc = r'C:\Program Files\Mozilla Firefox\firefox.exe'
ffTitle = "Mozilla Firefox"
ffApp = App(ffTitle) # app object "containing" all FF windows

-- comments so far:
--- r'some text' is a Python raw string - no need to double backslash
--- ffLoc is needed to open the app
--- ffTitle string identifies a window belonging to Firefox

if FF is not open, we want it to open with a new window
-- solution 1 (if active, not brought to front) 
if not ffApp.window():
    App(ffLoc).focus() # opens FF
# if not active, FF will open 

-- solution 2 (if active, FF brought to front) 
if not ffApp.focus():
    App(ffLoc).focus() # opens FF
# if not active, FF will open

details see: http://sikuli.org/docx/globals.html#controlling-
applications-and-their-windows

after this you use ffApp to deal with the active FF windows

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