Usage:
- Open Automator
- File > New > Choose "Quick Action"
- In the left sidebar, find "Library" > "Utilities" > "Run AppleScript" > double click it
- Copy & Paste the code above to the code section in the "Run AppleScript" panel you just added
- "Command + S" to save, give it an action name, such as "Lookup a word in Google"
- System Preference > Keyboard > Shortcuts, select "Services" in the list, and find "Lookup a word in Google"
- Click to add a keyboard shortcut for this action, e.g. Command + Shift + 1
- Now select a word with mouse and press the keyboard shortcut, it should open a Google Chrome tab with the google translate page open
The selected text doesn't get copied into in Google translate for me - I have to command-C and then paste. Is there a way to make the script copy directly? I'm on Big Sur.
Solution
In Automator, at the top of the window choose 'text' in the dropdown menu to get:
'Workflow receives current text in any application'