AppleScript: Tell Google Chrome to activate/deactivate extension I want to have AppleScript activate/deactivate a plugin, using a keyboard command.

I have set the keyboard command in Google Chrome > Settings > Extensions > Keyboard shortcuts and it works when I do it manually. For this example, I'm using Shift + Alt + U.

I've tried a few variants of this script.

tell application "Google Chrome" to activate
tell application "Google Chrome" to key code u using {option down, shift down}
delay(1)
tell application "Google Chrome" to keystroke "r" using command down


The last past refreshes the window, and it works – but not the second line which is supposed to toggle the extension. Again, I can toggle the extension manually with Shift + Alt + U, but the script won't do it,

I also tried this:

tell application "Google Chrome" to keystroke "u" using {option down, shift down}


Is the script actually supposed to work, making the problem reside somewhere else, or is there something wrong in it?
Try this code instead.

tell application "Google Chrome" to activate
tell application "System Events" to keystroke "u" using {option down, shift down}
delay(1)
tell application "System Events" to keystroke "r" using command down


I actually ran this applescript along with yours. First time I did not test yours seeing you called for a key code but gave it a keystroke value. When I ran your code, it gave me syntax errors(even with proper key code and keystroke values). When I ran my code, it compiles properly and runs the script as intended.