ATLChris
ATLChris

Reputation: 3296

Open URL and Activate Google Chrome via Applescript

I have the following AppleScript that I wrote many years ago. I use this code to program buttons on my Harmony One universal remote to access online video services via Google Chrome. The code is not working. Google Chrome doesn't launch. I am running the code via RemoteBuddy. The code complies fine, but does not work.

Anyone have any thoughts on what might be the problem, or how I can improve the script to make it work?

tell application "System Events" to set open_applications to (name of everyprocess)
if (open_applications contains "Google Chrome") is true then
        tell application "Google Chrome" to quit
else
        tell application "Google Chrome"
                activate
                open location "http://xfinitytv.comcast.net"
        end tell
        delay 1
        tell application "Google Chrome" to activate
end if

Upvotes: 30

Views: 49552

Answers (3)

helmett
helmett

Reputation: 11

osascript -e 'tell application "Google Chrome" to open location "http://yourlink.com.html"'

Upvotes: 1

Duckyy
Duckyy

Reputation: 101

tell application "Google Chrome"
    open location "http://WEBSITEHERE.com"
end tell

Upvotes: 10

user1804762
user1804762

Reputation:

Try it this way:

tell application "Google Chrome"
    if it is running then
        quit
    else
        activate
        open location "http://xfinitytv.comcast.net"
        delay 1
        activate
    end if
end tell



Note: it's using the newer "Enhanced Application Model" (second line), more info here:
How to check in AppleScript if an app is running, without launching it - via osascript utility

Upvotes: 44

Related Questions