AutoHotkey is a free, open-source scripting language for Windows that allows users to easily create small to complex scripts for all kinds of tasks, such as form fillers, auto-clicking, macros, etc. You can find more about it here: https://www.autohotkey.com/
In other words, it’s one of the safest ways to run custom scripts to automate simple tasks and create shortcuts on a Windows machine.
I started using AHK more than six years ago. At the beginning it was only to store commonly used passwords – which I’d advise against doing now – but that’s what got me started. I started reading blog posts and forums about it and discovered the crazy things some people did with it, and that gave me ideas. Over those last six years I’ve been creating small snippets and modifying some that I found to better suit my needs. They have become second nature to me, to the point where sometimes I’ll forget I’m on another machine when I’m still hitting the key combination for one of the snippets and it doesn’t work. They are simple things, but simple things can sometimes be very useful, so now I present them to you. Here’s a link to the code so you can follow the next points in this blog: https://gist.github.com/alvaro-ometis/696b0e0a13a94c6a0321791dd24401dc.
Replaces the string l8i
with the string
LOAD * INLINE [
];
and leaves your cursor in the second line.
Replaces the string $V
(uppercase V) with $()
and places the cursor in the middle of the brackets. This might only save a keystroke or two but after using it for a while I find it easier to type than the alternative.
If you select some text and hit Ctrl
+ Shift
+ 4
it will wrap the selected text with the dollar bracket expansion. E.g.: vDate
>> $(vDate)
If you select some text and hit Alt
+ [
it will wrap the selected text with square brackets. E.g.: Field with Spaces
>> [Field with Spaces]
Holding Alt
and scrolling up with the mouse scroll wheel will navigate to the previous (up) script section/tab in the Data Load Editor.
Holding Alt
and scrolling down with the mouse scroll wheel will navigate to the next script (down) section/tab in the Data Load Editor.
Holding Ctrl
and pressing the /
key will toggle comments on the Data Load Editor. This is currently available as Ctrl
+ K
but since pretty much all other code editors use Ctrl
+ /
I decided to create a shortcut for myself.
These last three are all targeted towards a specific internet browser since that’s where Qlik Sense lives for the most part. If you open the AHK script, you’ll see a commented section just above these three snippets of code where I listed the codes for the most commonly used browsers. You can edit the snippets to target your browser like this:
; [Qlik] - Hotkeys - [Alt] [Mouse Scroll Wheel Up] - Navigates to the previous script section
#IfWinActive ahk_exe chrome.exe
!WheelUp::PgUp
Where it says #IfWinActive ahk_exe chrome.exe
you can replace ahk_exe chrome.exe
with ahk_exe firefox.exe
to target Mozilla Firefox or any other browser code on the list.
Replaces the string ;hi;
with
Hi ,
Regards,
YOUR_NAME_HERE
And places the cursor just before the comma after “Hi” so you can type the name of the person who you’re writing to. Make sure you replace “YOUR_NAME_HERE” in the code with your actual name. This just makes my life easier when responding to emails or support tickets, especially to make sure I don’t make a mistake and sign with Retards instead of Regards – it almost happened a couple of times back when I manually typed it – it’s not good for customer satisfaction.
Holding Win
– the Windows key – and pressing C
will open Visual Studio Code, my code editor of choice, or switch to it if it’s already open. Sure you can just pin it to your taskbar and use Win
+ the number for the position it has on your bar, but if you have multiple windows opened, it’ll switch to your most recent one. It’s a small detail but, again, it makes my life easier which is the point of this.
Holding Win and pressing E
will open the Windows Explorer window or switch to it if there’s one open already. The first part, opening the Windows Explorer with Win
+ E
is a Windows thing, you can try it without running AutoHotKey and it should open the Windows Explorer. The issue with it is that if you do it again, it’ll open a new window. My function attempts to fix that and switches to the Explorer window if you have one open already.
Holding Win
and Shift
and then pressing E
will always open a new Windows Explorer window. This was necessary in order to have the ability to open a new Explorer window. I decided to use Shift
since it’s the same key Windows uses when you want to open a new window of one of the programs pinned to your taskbar.
Each function has a comment above that describes the type of function, how to trigger it, and what it does. Let’s break down one of the examples to see what it does:
; [Qlik] - Text replacement - l8i - Load * Inline
; e.g.: LOAD * INLINE [
;
; ];
:*:l8i::LOAD {*} INLINE {[}{Enter 2}{]};{Left 3}{Space 2}
[Qlik]
indicates the category or area of business that the code falls under. It’s more of an organising tool that helps me separate the code into areas, nothing strict. On this script you’ll find the following categories: Qlik, Support, and General.
Text replacement
tells us that the code below will be triggered by replacing text the user typed, in this case it’s the string l8i. The types of triggers I created are: Hotkeys, Text selection + Hotkeys, and Text replacement.
l8i
is the string of text the user has to type in order to trigger the execution of the code. When the trigger includes hotkeys it’ll be displayed like this [Ctrl] [/]
. This means the trigger is holding the key Ctrl and pressing forward slash.
Load * Inline
is a comment describing what the code does. In this case it generates the load * inline statement.
Finally, there might be an example section where the resulting code will be displayed. Not all the code sections have one since some open applications or interact with different windows. In this case we can see the load * inline statement:
; e.g.: LOAD * INLINE [
;
; ];
C:\Users\YOUR_USER_HERE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
shell:startup
and hit Enter or OK.Win
+ R
and type shell:startup
and hit Enter or OK.Here’s a list of resources that helped me on my quest for automation with AHK.
I hope you enjoy using this tool as much as I do. Feel free to leave a comment and let me know what you think!
By Álvaro Martínez