Search code examples
applescriptalfred

Open new chrome window with applescript alfred workflow



on alfred_script(q)

tell application "Google Chrome"
    if it is closed then
      activate
    end if
    else 
        make new window
        tell application "System Events" to set frontmost of process "Google Chrome" to true
        activate
    end else
end tell

end alfred_script

What is wrong is my appleScript code

I just want to open new terminal if google chrome is open otherwise just run the google chrome.

It will be a alfred work flow.


Solution

  • You don't need to work with process of an application.

    on alfred_script(q)
        
        tell application "Google Chrome"
            if its running is true then make new window
            activate
        end tell
        
    end alfred_script
    

    Note: you can omit is true as well. if its running then make new window