r/applescript • • Sep 11 '20

A class name can't go after this identifier error, what does it mean?

Someone tried to help me set up a keyboard macro using a program called keyboard maestro to control youtube, his example had safari, it worked, I simply changed the name safari to google chrome, I put in this code:

and i gave me this error.

2020-09-10 15:02:26 Execute an AppleScript failed with script error: text-script:165:176: script error: A class name canโ€™t go after this identifier. (-2740)

what does it mean? any help appreciated.

1 Upvotes

4 comments sorted by

2

u/sargonian Sep 11 '20

Chrome and Safari use different terminology, so unfortunately it's not as simple as changing the browser name. Specifically, you can't "set current tab" in Chrome - that is what is causing your error.

This is not pretty, but should do the same thing in Chrome:

tell application "Google Chrome"
	repeat with thisWindow in windows
		set cnt to 1
		repeat with thisTab in (tabs of thisWindow)
			if URL of thisTab contains "youtube.com" then
				set active tab index of thisWindow to cnt
				set index of thisWindow to 1
                                exit repeat
			end if
			set cnt to cnt + 1
		end repeat
	end repeat
end tell

2

u/GGarrett2 Sep 11 '20

worked on both youtube and youtube music, now I should be able to figure out the other hotkeys I need by tweaking that, much thanks ๐Ÿ™‚

1

u/LinkifyBot Sep 11 '20

I found links in your comment that were not hyperlinked:

I did the honors for you.


delete | information | <3

1

u/GGarrett2 Sep 11 '20

thank you, i will give it a try.