Saturday 15 January 2022

Working more efficiently with AutoHotkey (part 3)

Imagine having to press just one key combination to fire up all the programmes you need and be ready to start working instantly. AutoHotkey offers a simple way to do exactly that – and much more.

 

What is AutoHotkey?

AutoHotkey is a free, open-source scripting language for Windows for creating small to complex scripts for all kinds of desktop tasks. AutoHotkey enables you to define hotkeys for your mouse and keyboard, repurpose keys or set up autocorrect-like replacements, which you’ll love! 

 


 


More useful AutoHotkey scripts for translators and writers 

Given the popularity of my earlier blog posts about AutoHotkey (which you’ll find here and here), this blog post will introduce you to yet more immensely useful AutoHotkey scripts. They include: scripts for adding quotes or parentheses; scripts for performing Google or dictionary searches from any window; a script for saving a temporary version of text effortlessly; and a script for launching several programmes by pressing one key combination.

As always, remember that any text following a semicolon (;) below serves just as a comment, reminding you of what the script means or what you need to do to trigger it. It won’t be executed by the AutoHotkey programme.

 

Adding quotes or parentheses 

These scripts make sure that quotes or parentheses are added to text you’re just writing.

Example scripts:


; add quotes by highlighting text and then pressing WIN + 2:                   
#2::                       
    Send ^c
    Sleep 100
    clipboard = "%clipboard%"
    Send ^v
Return

; add parentheses by highlighting text and then pressing WIN + p:
#P::                       
    Send ^c
    Sleep 100
    clipboard = (%clipboard%)
    Send ^v
Return


Performing Google or dictionary searches from any window

With AutoHotkey it is possible to perform Google or dictionary searches from any window without having to perform Copy + Paste again and again and again:

Example scripts:


; highlight term or phrase and press CTRL+SHIFT+G to search in Google
^+G::                       
    Send, ^c
    Sleep 100
    Run, http://www.google.de/search?q=%clipboard%
    Return

; highlight term or phrase and press CTRL+SHIFT+D to search in Duden
^+D::                       
    Send, ^c
    Sleep 100
    Run, https://www.duden.de/suchen/dudenonline/%clipboard%
    Return
    
; highlight term or phrase and press CTRL+SHIFT+L to search in Linguee
^+L::                       
    Send, ^c
    Sleep 100
    Run, https://www.linguee.com/english-german/search?source=auto&query=%clipboard%
    Return

; highlight term or phrase and press CTRL+SHIFT+M to search in Microsoft Language Portal for English to German
^+M::                       
    Send, ^c
    Sleep 100
    Run, https://www.microsoft.com/en-us/language/Search?&searchTerm=%clipboard%&langID=354&Source=true&productid=0
    Return


Moving up one folder in Windows Explorer by pressing the middle mouse button

If you use Windows Explorer to navigate around your folder system, this script might come in useful: pressing the middle mouse button enables you to move one folder up in Windows Explorer.

Here is the script for it:

#IfWinActive, ahk_class CabinetWClass
~MButton::Send !{Up}
#IfWinActive
return



Saving a temporary version of text

This script (which has been proposed by Jack Dunning here) copies selected text to a text file which I’ve named SaveEdit.txt (which is stored in a folder which I’ve named Temporary). Each time I use the CTRL+ALT+s Hotkey combination, all the text in a document or web editing field, which I’ve just typed, is automatically selected, copied to the Windows Clipboard and then saved to the SaveEdit.txt file.

 


Note that this script only serves the purpose of temporarily backing up text which you’re just writing! The file is overwritten each time the script is used.

 

I love using this script:

^!S::                        ; CTRL+ALT+s                       
Send, ^a
Sleep 100
Send, ^c
Sleep 100
IfExist, C:\Users\User\Documents\Temporary\SaveEdit.txt
    {
        FileDelete, C:\Users\User\Documents\Temporary\SaveEdit.txt
    }
FileAppend, %clipboard%, C:\Users\User\Documents\Temporary\SaveEdit.txt
Click
return


Pressing one key combination to launch several programmes at once 

As mentioned above, AutoHotkey offers an amazing way to fire up several programmes with the pressing of just one hotkey combination!

I’ve defined WIN + n (which is what #n:: in the script stands for) as the hotkey combination to activate my script for launching, for example, the following programmes in one go: Outlook, SDL Trados Studio, my Clients folder, my UniLex Pro electronic dictionary application, and Chrome.

Here is the script for it:

#n::
Run Outlook.exe
Run C:\Program Files (x86)\SDL\SDL Trados Studio\Studio16\SDLTradosStudio.exe
Run C:\Users\User\Documents\Clients
Run C:\Program Files (x86)\UniLexPro\BSUniLexPro17.exe
Run Chrome.exe
return

 


 

AutoHotkey has simplified the computing lives of Windows users around the globe. It could also significantly simplify your life, so why not look into setting it up to enjoy the benefits of this amazing tool?
 
 
Check out my other blog posts about AutoHotkey: