Created
April 12, 2018 20:18
-
-
Save cdeutsch/9207f12e7b3618f78c2ca7d900c3a69d to your computer and use it in GitHub Desktop.
Toggle Play Pause in Google Chrome using AppleScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if application "Google Chrome" is running then | |
tell application "Google Chrome" | |
activate | |
repeat with w in (windows) | |
set j to 0 | |
repeat with t in (tabs of w) | |
set j to j + 1 | |
tell t | |
if URL starts with "http://www.youtube.com/watch" or URL starts with "https://www.youtube.com/watch" then | |
set (active tab index of w) to j | |
set index of w to 1 | |
tell application "System Events" to tell process "Google Chrome" | |
-- toggle play/pause | |
keystroke "k" | |
-- cmd+tab back to previous application | |
keystroke tab using {command down} | |
end tell | |
end if | |
end tell | |
end repeat | |
end repeat | |
end tell | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment