Rob Penfold | Peninsula Health

Keyboard shortcuts can be very effective in speeding up workflows. However, there are two main barriers to using them more extensively:

  1. They can be hard to remember. Programs, browsers, and operating systems can all have their own keyboard shortcuts. While there are sometimes commonalities, there are also many unique combinations, which makes it difficult to recall which keyboard shortcuts apply in which context.
     
  2. There can be too many for a specific program. If you bring up the dialog for keyboard shortcuts that can be used for a given program, they often provide too many options, which can make it difficult to find the specific shortcuts you are after.

 

This short article will describe an approach that requires remembering just one – yes 1 - single solitary keyboard shortcut, and that will display a custom list of keyboard shortcuts specific to the program or website being used at the time. In that sense, it’s a bit similar to a password manager in that instead of remembering those numerous login details which accrete inexorably over time, you just need to remember one to access the password manager. It uses a free program, and doesn’t necessarily require installation on the computer which makes it broadly usable in most workplace settings.

 

Before I go on, a confession concerning the appealing “universal” component of the title. This – alas – is just good old click-baiting at work. If you use a Mac or Linux computer at work, then it is probably better at this point that you switch to another more truthful article in JoHILA. However, the vast majority of workplaces use Windows, so this approach should be widely applicable (aka “near universal”).

 

The script (don’t worry – you don’t have to be technically minded to adapt it to your own circumstances) described in this paper essentially does two things: 

  1. It is context aware. This means it will only display the shortcuts menu when the program or website that you have specified has focus.
     
  2. It is customisable. You can add whatever text you want to make the pop-up menu meaningful to you.

Down to the nitty gritty. The program involved is AutoHotkey (version 1.1) and it can be downloaded from www.autohotkey.com (> Download > v1.1). It is probably best to do this on your home computer or laptop initially, before migrating it to the work setting. 

 

Steps:

  1. Install AutoHotkey 1.1. as above
  2. Right click anywhere on the desktop, and navigate to New and then AutoHotkey Script
  3. A new Notepad file will appear on your desktop called New AutoHotkey Script
  4. Rename it to Shortcuts and save
  5. Open Shortcuts, copy the text from Appendix 1, paste it into the file and save (it will save with an ahk extension)
  6. Double click on the Shortcuts file to run it
  7. A green box with a white H should appear on the bottom right of your taskbar (note – it may be hidden in the up arrow section; if yes you can drag it out so it is visible on the taskbar).

 

With any luck, you will now have the script from this article running. If the specified program or website has focus, then a popup will display when Ctrl 9 is pressed. You can test by opening Notepad, and when the Ctrl 9 is pressed, you should see a pop up with a few keyboard shortcuts.

 

Similarly, if you have Google Calendar open in the browser, then pressing Ctrl 9 will display some keyboard shortcuts specific to that site. Worked initially and then stopped? There is only ever one pop up visible, so if you have opened it for one program or website, then you need to close it before a new one will appear for the next program / website.

 

That’s nice and all, but much better if you can customise to your own programs / websites and keyboard shortcuts.

 

  1. Websites. These are easy to customise as the context specific response is just based on a specific word in the URL. So the YouTube pop up will appear (after Ctrl 9 is pressed) on any site where the URL contains the string youtube. To adapt to Outlook accessed on the web for example, you can simply substitute outlook for youtube in the script, and now the message will only appear when you are checking your Outlook email in the browser. The script gives examples of two sites but you can create unlimited numbers – just copy the Else If block (down to the closing bracket) and modify as desired. The provided script currently covers Chrome, Firefox and Edge – this means you can get the context specific pop up in any of those browsers.        If you want to use another browser, just follow the process given in Applications below to get the correct title and add it to the Browser Support section of the script.
     
  2. Applications. These can also be easily modified. So for instance, if you don’t want any shortcut messages for Notepad, you can replace notepad.exe with the name of the program you want the context specific message to appear on. To find the required name for the program, first open it (for example Excel). Now, right click on the system tray green box (described above) and choose Window Spy, which will lead to a pop up appearing. With the pop up on top of Excel, it should show something like ahk_exe EXCEL.EXE near the top of the pop up. So now just replace notepad.exe with EXCEL.EXE and your pop up window is now specific to Excel. As with websites, as many applications as wanted can be added just by duplicating a block, and editing appropriately. This same approach can also be used on browsers to find the correct browser name (see 1. Websites).
     
  3. Pop up menu. Any reminder text you like can be added in here. An approach that I find works quite well is to list actions alphabetically which allow for easy scanning of the pop up. Then for each action, supply the keyboard shortcut after it (along with any addition explanatory text appended if useful). It is not necessary of course to use the keyboard shortcut descriptions as provided by the app. Instead, you can describe them in a way that makes sense to you. Additionally, you can choose to just include the ones you find useful and / or can never remember. The alignment of text in the pop up is not perfect but it is good enough to be usable.

 

With any luck, you need never forget a keyboard shortcut again. However, that is on your home computer, what about work? A minority of places allow installation of programs (or perhaps this can be requested from your IT department). However, in many cases this may not be possible at all. In this case, the portable version of AutoHotkey may come to the rescue (it has in my specific work situation). This is available at https://portableapps.com/node/39299   (click on the 1.1 version, it will take you to a mirror site). Move the download onto a USB stick and double click it to install on the thumb drive. Place any scripts you create on the thumb drive and then use at work as above.

 

(In passing, it can be noted that PortableApps combined with a USB stick can be a useful option in a locked down IT environment, as it allows you to run other useful programs such as Notepad++ (programming), GIMP (image editor), ShareX (screenshots), Greenshot (screenshots), CamStudio (video producer), TinyTask (simple macro record and playback – can be quite useful if you have a very repetitive task).

 

 

 

AutoHotkey can do many many other things, but just two bonus tips while I’m here:

 

  1. Text expander. You often have to type out the same information multiple times – website addresses, email addresses, phone numbers and so on. The Text Blaze extension, as described in Browser Extensions for the Stretched Health Librarian, does this but only works in the browser. For a version that works both on the web and in any Windows program (Universal perhaps?), you can instead use AutoHotkey. The hotstring below will produce my work email (note in passing – happy to try and answer any questions you may have if you try the script) when backslash followed by we (for work email) is typed anywhere. If you follow that general pattern, many useful hotstrings can be created for your specific needs. These can just be listed after the Return in the script provided with the paper (Appendix 1)

 

:0*:/we::robpenfold@phcn.vic.gov.au 

 

  1. Key remapping. Sometimes you may want to remap a key to another one. The remapping below means that tapping the right Alt key on the keyboard now behaves like clicking the right mouse button on a website

 

RAlt::RButton      


 If you find a script useful, you may like it to start every time the computer does. Right click on the script file and Create Shortcut. Then press the Windows key, type Run and in the resulting screen shell:startup. Cut and paste the shortcut link into that window and now the script will start with the computer. 

 

Finally, you don’t need to be a programmer to gain value from AutoHotkey. The other day I asked ChatGPT to write some AutoHotkey code for a somewhat complex task. It completed this quickly and the script worked as desired.

 

Appendix 1. Template script (copy everything below)


 #SingleInstance force


 ; 0. COMMENT - comments appear after a semi-colon and don't affect the script

 

; 1. PURPOSE - This script will display a list of custom keyboard shortcuts when Ctrl 9 is pressed, in a context-sensitive manner, for specified programs and websites. Ctrl 9 (indicated in the script as ^9) doesn’t have to be used – it can be replaced by another keyboard shortcut as desired. Refer to AutoHotkey documentation.

 

; 2. BROWSER SUPPORT - The stanza below specifies what browsers are supported. You can add or remove browsers as per the article instructions.


 GroupAdd, Browsers, ahk_exe chrome.exe

 

GroupAdd, Browsers, ahk_exe firefox.exe

 

GroupAdd, Browsers, ahk_exe msedge.exe

 

; 3. APPLICATIONS

 

; For Notepad

 

#IfWinActive ahk_exe notepad.exe

^9::MsgBox, 

 

            (LTrim

 

        Save - Ctrl S

        Search - Ctrl F

        Search / Replace - Ctrl H

        Time/Date - F5

 

            )

 

#IfWinActive

 

; For Evernote

 

#IfWinActive?, ahk_exe Evernote.exe

^9::MsgBox,

 

            (LTrim

 

            Body - ALT B 

            Collapse (side) - F10

            Highlight - ALT I

            Home - ALT H

            Keyboard shortcuts - CTRL /

            Link - Alt L (insert Note Link)

            Menu - ALT then arrows

              Move  - ALT M (to Processed)

            Move   - ALT P (to PBD)

              Search - ALT S (advanced like tag:p1, search one tag, do again to add another)

            Search - ALT Q (recent, tags, notebooks, saved searches)

            Search - CTRL F (find within a note, when in note)

            Shortcuts - CTRL 1-9 to select (so Inbox Ctrl 2)

              Tag   - ALT G (when in note)

               Title - ALT T

 

            )

 

#IfWinActive

 

 

; 4. WEBSITES

 

#IfWinActive ahk_group Browsers

^9::

            WinGetActiveTitle, WinT

    

            If InStr(WinT,"youtube")

                        MsgBox,

 

                        (LTrim

 

                        Captions - C (if available)

                        Forward 5 - Right arrow

                        Fullscreen - F

                        Mini player - I

                        Mute / Unmute - M

                        Play / Pause - Spacebar or K

                        Search - /

                        Speed up - > (ie Shift dot)

                        Volume - Up and down arrow keys

 

                        )

 

            Else If InStr(WinT,"calendar")

                        MsgBox,

 

                        (LTrim

 

                        Day   -   D

                        Week  -   W

                        Month -   M

                        Year  -   Y

                        Sched -   A

 

                        Search - /

 

                        Previous - P

                        Next     - N

                        Today    - T

                        Go to Date - G (default to today, then C for create)

 

                        Create     - C

                        Edit          - E

                          Save         - Ctrl S

 

                        )

 

Return