Showing posts with label AutoHotkey. Show all posts
Showing posts with label AutoHotkey. Show all posts

Wednesday, 9 November 2022

Getting started with AutoHotkey

Getting started with AutoHotkey is easy. Simply follow the 6 steps below. Once you’ve defined your first hotstring, you won’t want to live without AutoHotkey afterwards!

 


(Note: AutoHotkey only runs on Windows, so your computer has to be a Windows computer.)


Step 1:
Download AutoHotkey from https://www.autohotkey.com onto your computer and install it.


Step 2:
Right-click on your desktop, select “New”, then select “AutoHotkey Script”. You can change the name of your AutoHotkey file if you like.


Step 3:
Right-click your AutoHotkey file on your desktop and open it in Notepad or any plain text editor.


Step 4:
Ignore the first few lines of text that already are in your AutoHotkey file. Type your first script underneath. To begin with, you could use this script, for example (or use your own name!):

::dd::Donald Duck

 

Note: there must be no spaces between the colons, your abbreviation and Donald Duck!


Step 5:
Save your AutoHotkey file.


Step 6:
Activate your script by double-clicking the AutoHotkey file on your desktop.
(Remember to carry out this step every time you add a new script to your AutoHotkey file.)

 

And that’s it! You’ve just defined your first hotstring in AutoHotkey. The script is now running on your computer. The next time you type “dd”, it will automatically be expanded to “Donald Duck”.

 

You may add as many hotstrings underneath in your AutoHotkey file as you like. Find abbreviations that will be easy for you to remember, for example:


::dd::Donald Duck
::tte::Thomas the Tank Engine
::lrrh::Little Red Riding Hood
::ppl::Pippilotta Rollgardinia Victualia Peppermint Longstocking



Note: when you double-click your AutoHotkey file the next time, the following message will appear: “An older instance of this script is already running. Replace it with this instance?” Click “Yes”.




Once you’ve defined your first hotstring,
you won’t want to live without
AutoHotkey afterwards

(Image by Tommmy_ on Pixabay)

 

Do check out my other blog posts about AutoHotkey, in which I share many more useful scripts for translators and writers. They will help you save precious time on routine computer tasks!

 

Working more efficiently with AutoHotkey (part 1)

Working more efficiently with AutoHotkey (part 2)

Working more efficiently with AutoHotkey (part 3)

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:
 



Sunday, 25 July 2021

Working more efficiently with AutoHotkey (part 2)

AutoHotkey is a must-have tool that anyone (with a Windows computer) can use to improve their Windows experience. If you’re tired of constantly navigating menus or using multiple strokes to perform repetitive tasks and would like to simplify your work life, then AutoHotkey and the scripts below will be for you!

AutoHotkey has much more power than most people will ever use, but also offers very simple scripts. Its simplest scripts – typically just one line of code – could even turn out to be those that you'll find most useful in your day-to-day computing! 

 

A few examples: whenever I type tn, the AutoHotkey script will automatically enter the word translation. Or when I enter @@k, the script will automatically enter my email address. I remember that, before I started using AutoHotkey, it would always be a pain to constantly have to type the whole email address! Check out my earlier blog post about AutoHotkey to find out more about this.

 


Teaming up with an AutoHotkey accountability partner 

A couple of months ago I teamed up with Isabel Hurtado de Mendoza, an English-to-Spanish translator. We both had only scratched the surface of what is possible with AutoHotkey then and were keen to find out more about it. So we became accountability partners: we now report back (more or less) regularly to each other on our latest AutoHotkey discoveries and learning progress. 

Isabel and I identified AutoHotkey scripts that are particularly useful to translators as well as other computer users. We either adopted existing AutoHotkey scripts (many of which are readily available on the web) or modified and adapted them to our own purposes. You’re very welcome to adopt the scripts below as well!


Simpler AutoHotkey script editing with SciTE4AutoHotkey

I would previously edit my AutoHotkey scripts in Notepad, but recently switched to SciTE4AutoHotkey upon Isabel’s recommendation. SciTE4AutoHotkey is an AutoHotkey script editor, which provides helpful features such as syntax highlighting (to highlight any errors in AutoHotkey syntax), AutoComplete, interactive debugging and others. This might all sound very complicated, but it really isn’t!

 


Advanced AutoHotkey scripts for translators
 

The following AutoHotkey scripts are slightly more advanced AutoHotkey scripts. You’ll find a number of useful, simpler scripts in my earlier blog post about AutoHotkey.
 

Note that any text following a semicolon (;) below serves 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.


Launching programmes by pressing a combination of keys 

It is possible to launch any programme instantly by using a hotkey. For instance, you could set up AutoHotkey to launch Outlook and define, for example, WIN + o for this. In other words, when you press WIN + o, this will launch Outlook.


Here are some example scripts which could be used:
 

;>>>>>>>>>>>>>
; Programme ausführen/Run programmes
;>>>>>>>>>>>>>

; press WIN + o
#o::
Run Outlook.exe
return

; press WIN + f
#f::
Run firefox.exe
return

; press WIN + m
#m::
Run MicrosoftEdge.exe
return

; press WIN + c
#c::
Run calc.exe
return

Note: in AutoHotkey # designates the Windows key on your keyboard.


Creating a new file in Word or Excel

In the past, I always had to perform several clicks to create a new Word or Excel file. Now, I can create one instantly by simply pressing CTRL (or, to be more precise, Strg on my QWERTZ keyboard) + n to create a Word file and CTRL + SHIFT + % to create an Excel file, respectively.


Here are the scripts:

;>>>>>>>>>>>>>
; Neue Word-Datei/New Word file
;>>>>>>>>>>>>>

; press CTRL + n
^n::
Word := ComObjCreate("Word.Application")    
Word.Visible := True                        
Word.Documents.Add                          
Return

;>>>>>>>>>>>>>
; Neue Excel-Datei/New Excel file
;>>>>>>>>>>>>>

; press CTRL + SHIFT + %
^%::
Xl := ComObjCreate("Excel.Application")     
Xl.Visible := True                             
Xl.Workbooks.Add                             
Return   

Note: in AutoHotkey ^ designates the CTRL key on your keyboard.




Entering the £ symbol

I do a lot of business with UK companies, so I use the £ currency symbol all the time; however, since I use a QWERTZ keyboard, I don’t have a £ key on it. Thanks to AutoHotkey, though, I can enter it quickly by pressing CTRL + WIN + p.


Here is the script for it:

; create the £ sign by pressing CTRL + WIN + p
^#P::SendInput {U+00A3}  

Note: in AutoHotkey # designates the Windows key on your keyboard.

 



Creating message templates

AutoHotkey can be utilized to create message templates for use not just in an email client, but anywhere in your Windows environment, for example when writing messages in a web-based interface.


Here’s an example script for it:

;>>>>>>>>>>>>>
; E-Mail-Vorlagen/Email templates
;>>>>>>>>>>>>>

; type jobno
::jobno::Dear XX,{ENTER}{ENTER}Thank you for your new enquiry.{ENTER}{ENTER}I am sorry I'm unable to take on the project as I’m currently fully booked.{ENTER}{ENTER}Kind regards,{ENTER}{ENTER}Elisabeth




Taking a screenshot

This is a script for effortlessly taking a screenshot using Paint, combining several steps. To take a screenshot, I simply have to press CTRL+ALT+1, and all that’s left for me to do is to save the Paint file (with the screenshot in it) on my hard drive (or another storage medium).


Here is the script for it:

;>>>>>>>>>>>>>
; Screenshot erzeugen und in Paint kopieren/Take screenshot and copy it to Paint
;>>>>>>>>>>>>>

; CTRL+ALT+1
^!1::                       
sleep, 100
send {PrintScreen}
sleep, 500
Run, C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Paint
Sleep, 1000
Send, #{Up}
Sleep, 500
Mouseclick, left, 250, 250, 5
Sleep, 200
send ^v
sleep, 500

Note: Isabel and I figured out that sometimes it’s necessary to write the whole file path in the script (such as C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Paint in the script above), rather than just write “Run Paint”!


Converting a short dash to an m dash


Entering an m dash should be easy, but for some reason it often isn’t! Using an AutoHotkey script can help make sure the m dash always is there when you need it.


I now use this script:

; press Alt Gr + -
<^>!-:: Send, –                

Note that similar scripts could be used for any symbols that you use regularly, for example a script that changes square brackets to curly brackets.

 

The simplest AutoHotkey scripts – typically just one line of code – could turn out
to be those that you'll find most useful in your day-to-day computing
(image by Gerd Altmann on Pixabay)

 




Copying and pasting text into an open Word file


Collecting data while I’m researching terminology during a translation project has become way more comfortable thanks to the following script in that I no longer have to jump around between windows!

These days I only need to have a Word file open on my screen, and any text which I highlight (e.g. on a webpage or in an electronic dictionary) will then automatically be copied to this file by the script. I’ve named this file notes.docx, which is why the lines IfWinExist, notes and WinWaitActive, notes are used in this script, as shown below.



To trigger the script, I only need to press CTRL+ALT+n.



;>>>>>>>>>>>>>
; Text in Word-Datei notes.docx kopieren/Copy text to Word file notes.docx
;>>>>>>>>>>>>>

; CTRL+ALT+n   
^!n::                       
Send, ^c
IfWinExist, notes
{    
    WinActivate
}
else
{
    Run winword
}
WinWaitActive, notes
Send, ^v`n`n
return





This blog post lists a number of slightly more advanced AutoHotkey scripts that are particularly useful to translators as well as other computer users. They are designed to save time and take the dullness out of performing repetitive computing tasks, for example when taking screenshots, writing messages or entering special symbols.  I hope you like them and they will make your life a bit easier!


Check out my other blog posts about AutoHotkey:
 
Working more efficiently with AutoHotkey (part 1)
Working more efficiently with AutoHotkey (part 3)




Thursday, 1 October 2020

Working more efficiently with AutoHotkey (part 1)

AutoHotkey has recently started making a notable difference to my computing life in that I can now, relatively simply, automate certain repetitive tasks and hence work more efficiently. AutoHotkey is a free, powerful tool for writing scripts that will run in any Windows application. It’s beginner-friendly, so previous coding experience is not required. I highly recommend this tool!

 



My attention had been drawn to AutoHotkey following the publication of an ITI Bulletin article about it by Richard Lackey MITI and two posts on his blog in which he explained the basics of AutoHotkey and listed AHK scripts useful to translators.

 

I find AutoHotkey intriguing also because I’ve always been fascinated by IntelliWebSearch, which is based on AHK scripts. What’s more, AutoHotkey hotstrings work exactly like the Autocorrect feature in memoQ, which I rely heavily on for those recurring long compound nouns in patent translations.

AutoHotkey can be downloaded from www.autohotkey.com. To write a script, you then create and run an .ahk file, which you can later edit in a simple Notepad programme whenever you wish to change or add to the script.

 

Text expanders

 
The most typical use of AutoHotkey is the creation of hotstrings to expand abbreviations into full text. To give a simple example, typing the string thx will automatically produce the following sentence: “Thank you for your email”. This is my script for it:

::thx::Thank you for your email.
 

When I type tn, the script will enter the word translation. Here’s the script: 

::tn::translation


When I type @@k, the script will enter my email address kontakt@hippe-heisler.de. Here’s the script:


:*:@@k::kontakt@hippe-heisler.de

 

(Note: Using the asterisk * means that an ending character, e.g. Space, ., or Enter, is not required to trigger the hotstring.)
 

 

Instant access to folders or websites
 

When I press the Ctrl key in combination with the dollar sign on my keyboard (i.e. Ctrl + Shift + 4), the script will instantly open my folder for the 2020-21 tax year. Here’s my script:
 

^$::                        
Run, C:\Users\User\Documents\Accountancy\Cash Books tax year 2020-21
Return

 

(Note that in AutoHotkey ^ stands for the Control key.)

 

To access TweetDeck, I first press the Alt Gr key and then the t key. Here’s my script:


<^>!t:: Run, https://tweetdeck.com/


To access Woxikon (a site for German synonyms), I press the Alt Gr key and then the d key. Here’s the script:
 

<^>!w:: Run, https://synonyme.woxikon.de/


(Note that in AutoHotkey <^>! stands for the Alt Gr key.)

 

Quick access to several folders, displayed in a pop-up menu
 

This is a slightly more complex script that enables me to access, in an instant, the folders which I (currently) visit most frequently, for which I simply have to press the Alt key and x. The folders will then be displayed in a pop-up menu (at the location of my cursor).

 


This is my script for it (which needs to be written into a separate AHK file, not the one already created for other AHK scripts!):


Menu, Folders, Add, &Downloads, !1
Menu, Folders, Add, &OneDrive, !2
Menu, Folders, Add, &Murgitroyd, !3
Menu, Folders, Add, &Terminology lists, !4
Menu, Folders, Add, &Patent translation, !5
Menu, Folders, Add, Temporary, !6

!x:: Menu, Folders, Show

!1:: Run, C:\Users\User\Downloads       
Return

!2:: Run, C:\Users\User\OneDrive
Return

!3:: Run, C:\Users\User\Documents\Clients\Murgitroyd
Return

!4:: Run, C:\Users\User\Documents\Terminology lists
Return

!5:: Run, C:\Users\User\Documents\Patent translation
Return

!6:: Run, C:\Users\User\Documents\Temporary
Return


(Note that in AutoHotkey ! stands for the Alt key.)

 

Adding the ampersand symbols (&) to the script above has the effect that I don’t even have to use the mouse to open any of the folders in the pop-up menu. Instead, when I open the pop-up menu (by using Alt + x), pressing the letter d on my keyboard activates Downloads, the letter o activates OneDrive, and so forth.
 

Note that not including an ampersand symbol before Temporary in the Menu, Folders, Add, Temporary, !6 line means that I do have to use the mouse to open a folder which I’ve called Temporary (since pressing t will open my Terminology lists folder).

 

Finally, a word of caution, as also pointed out by Richard in his article: do be careful of any AHK scripts which you find on the internet as they have the potential to do anything assigned (even in an extreme case to wipe your hard drive!). It is vital that you understand the code before running any scripts.


AutoHotkey is a free, powerful tool for writing scripts that will run in any Windows application. It is used to automate certain repetitive tasks. AutoHotkey can make a huge difference to your computing life!