Applescript for Active Tab in Google Chrome

I have a number of macros which help me to automate Google Chrome in various ways. They have worked fine for a while.

Today these macros stopped working. What they all have in common is that the property active tab will no longer compile in either Script Editor or Keyboard Maestro.

Any idea why this used to work but now has stopped working?

image

Chrome doesn't always have any open windows, but provided that it does, this seems to be working:

tell application "Google Chrome"
    if 0 < (count of windows) then
        tell front window
            {title, URL} of active tab
        end tell
    else
        "No windows open in Chrome"
    end if
end tell

with Chrome Version 86.0.4240.198 (Official Build) (x86_64)

on macOS 10.15.7

Thank you

While that syntax works, I realized the problem is that for some reason Neither KM nor Script Editor is responded to application "Google Chrome" - I have to instead change it to application "Chrome" and then it compiles and it switched to application "Google Chrome."

1 Like

Hmm... How long since you rebooted your system?

-Chris

Did during my debugging of this problem and again very recently - no change

I'd reinstall Chrome.

I just installed the newest release version: 86.0.4240.198.

No problems observed on macOS Sierra.

Could you have more than one version of Chrome on your system?

-Chris

I do have Chrome open on both the Mac side and under Parallels - maybe that is the cause?

Hey @rkaplan,

Hmm... That rings a faint bell from years ago: Parallels AppleScript Problem.

First try this:

tell application id "com.google.Chrome"
   path to it
end tell

If that fails to work then try using the specific path:

tell application "Mercury:Applications:Applications_Chris:Internet_Apps:Web_Browser_Apps:Google Chrome:Google Chrome.app:"
   path to it
end tell

Get the path using this script:

tell application "Finder" to set finderSelectionList to selection as alias list
if length of finderSelectionList = 0 then error "No files were selected in the Finder!"
set theItem to item 1 of finderSelectionList as text

set the clipboard to "\"" & theItem & "\""

-Chris

1 Like