Cedeq Community Forum
Keyboard Shortcut - Launch Google Translate for Selected Text - Printable Version

+- Cedeq Community Forum (https://cedeq.com/forums)
+-- Forum: General (https://cedeq.com/forums/forumdisplay.php?fid=1)
+--- Forum: Keyboard shortcuts with AutoHotkey code (https://cedeq.com/forums/forumdisplay.php?fid=4)
+--- Thread: Keyboard Shortcut - Launch Google Translate for Selected Text (/showthread.php?tid=517)

Keyboard Shortcut - Launch Google Translate for Selected Text - pilot888 - 10-17-2019

Often at my work, I need to translate documents received from international customers when English is not used. Typically, after selecting the text (from anywhere), you have to copy it (to the clipboard), start your browser, go to Google Translate, paste it (from the clipboard) in the query field, and then click a button to translate. This whole process can be very long and repetitive.

To solve this, I developed a quick AutoHotkey script to process the translation into Google Translate. I select the non-English text, then I activate the shortcut from Shortkeeper. Immediately after, Google Translate opens up in my internet browser and instantly shows me the English version of the text. Here's the AutoHotkey script to be used in Shortkeeper:

ClipSaved := ClipboardAll
Clipboard =
SendInput, ^c
ClipWait, 2
if ErrorLevel
  run % "https://translate.google.ca/#view=home&op=translate&sl=en&tl=fr"
  SelectedText := Trim(Clipboard)
  SelectedText := StrReplace(SelectedText, """", "%22")
  run % "https://translate.google.ca/#view=home&op=translate&sl=en&tl=fr&text=" . SelectedText
Clipboard := ClipSaved

Note that you can change the input and output language, to whatever language Google Translate supports, by changing the ''en'' and ''fr'' in the URL address to your preferred language code. In this example, I translate from English to French.

This shortcut is by far a game changer and ultimately saves me lots of precious time at work. Hope you enjoy it as much as I do!

RE: Keyboard Shortcut - Launch a Google Translate for Selected Text - denilama - 10-18-2019

Thanks for sharing. The script works very well.

This short tutorial "https://cedeq.com/forums/showthread.php?tid=29" will help someone needing help to create a keyboard shortcut with ShortKeeper using AutoHotkey code.