views:

297

answers:

3

Is there a way to do this to Chrome?

tell application "Google Chrome"
 return URL of front document as string
end tell

... doesn't work.

+1  A: 

Since there is no applescript support the only way it can be done is through GUI scripting, I'm not sure how familiar you are with applescript but gui scripting is a bad practice to get into. so take this code with caution. it is also important that you have access for assistive devices ENABLED in your Universal Access preferences.

  tell application "Google Chrome"
    activate
    tell application "System Events"
        tell application process "Google Chrome"
            get value of text field 1 of tool bar 1 of window 1
        end tell
    end tell
  end tell
mcgrailm
why have you not accepted a single answer to any of the questions you have posted ? also you have been a member for a year and have given absolutely nothing back to this community please take the time to accept answers given and please consider giving back to it.
mcgrailm
I didn't know about accepting answers until now, thanks.
dmd
ahh ok, yes it is very good practice to get into
mcgrailm
dmd
Er, ok, how do I make it format right?
dmd
you can't put code in comments they are just comments you can edit your question and put your final code at the bottom making sure you mark it
mcgrailm
+1  A: 

Now that Chrome (7+) supports AppleScript, you can do this:

tell application "Google Chrome"
    get URL of active tab of first window
end tell

Note: "first window" refers to the frontmost window.

Guillaume Boudreau