software solutions / project leadership / agile coaching and training

What’s in my AutoHotKey file

Posted on September 7, 2010

I was asked awhile back to blog about what is in my AutoHotKey script file. If you don’t know what AutoHotKey is, it allows you to remap keys on your keyboard or create macros that are associated with keystrokes or key combinations. So here’s what I got.


#SingleInstance says that if I load up my AutoHotKey script and there is already one loaded, then just use the new one without prompting. If you make changes to your script file, you can double click the file to reload it. This way you won’t get annoying prompts when you do so. This has to be the first line in your AHK file if you use it.

SetKeyDelay, -1

By default, AHK puts a slight delay between each keystroke in a macro. I have no idea why you would normally want this, so the above line removes that delay and it will execute the keystrokes as fast as possible.

Send {End}

Remaps Caps Lock to End. The Caps Lock key is in such a prime location in the home row, and you don’t usually need to use it. So I remap it to End, which I use a lot when I want to go to the end of a line of code. This way, I don’t have to take my hands off the home row and stab at the End key (and often miss). This was my first AutoHotKey shortcut and it still my favorite.


Shift-Caps Lock will now toggle Caps Lock. Because sometimes you actually do need Caps Lock.

#j::run explorer c:proj

Windows+J opens the folder where I keep all of my code. The “run” keyword allows you execute whatever you want.

Send {Up}{Up}{Up}{Up}{Up}

Send {Down}{Down}{Down}{Down}{Down}

Send {Left}{Left}{Left}{Left}{Left}

Send {Right}{Right}{Right}{Right}{Right}

When I hit Ctrl-Alt-arrow key, it will go 5 characters/lines in that direction. This really helps you move around faster in a code file. Ctrl-left arrow or Ctrl-right arrow will go to the beginning/end of the current word, which is nice, but sometimes you want to go to a spot in the middle of a long word, so the Ctrl-arrow doesn’t really help. This is another favorite of mine.

SendEvent select * from `

When I type “ssf]”, it will change it to “select * from “. The tick at the end of the second line tells AHK that the space at the end of the line is important and should be included.

SendEvent if exists (select 1 from sysobjects where name = 'TableName' and xtype = 'U'){Enter} drop table [dbo].[TableName]{Enter}{Backspace}go

SendEvent if exists (select 1 from sysobjects where name = 'ViewName' and xtype = 'V'){Enter} drop view [dbo].[ViewName]{Enter}{Backspace}go

SendEvent if exists (select 1 from sysobjects where name = 'TriggerName' and xtype = 'TR'){Enter} drop trigger dbo.TriggerName{Enter}{Backspace}go

SendEvent if exists (select 1 from sysobjects where name = 'ProcName' and xtype = 'P'){Enter} drop procedure [dbo].[ProcName]{Enter}{Backspace}go

SendEvent if exists (select 1 from sysobjects where name = 'ProcName' and xtype = 'P'){Enter} drop procedure [dbo].[ProcName]{Enter}{Backspace}go{Enter}{Enter}create procedure dbo.ProcName{Enter}({Enter}{Enter}){Enter}as{Enter}begin{Enter}{Enter}end{Enter}go{Enter}{Enter}grant execute on dbo.ProcName to EdwardsSteelUser{Enter}go

Prints out the following code when I enter “ietable]”:

if exists (select 1 from sysobjects where name = ‘TableName’ and xtype = ‘U’)
drop table [dbo].[TableName]

I put this at the top of the file every time I create a new database table. Also included are similar macros for views, triggers, functions, and stored procedures.

SendEvent ShouldEqual(

When I write tests, I’m often writing things like “employee.Name.ShouldEqual(“Jon”);”. When I’m typing this stuff, I can just type “se]” and get “ShouldEqual(“. Sure, Intellisense could do it for me, but AHK is a lot faster than waiting for Intellisense to figure out what I’m doing.

SendEvent c:

Because I often screw up when typing “c:” and type “c:|” instead. You can do similar things for common misspellings that you often find yourself typing.

I have some other project-specific macros in my AHK file too. If you find yourself typing the same class name, database table name, or anything else over and over, create a macro for it. It’s a small thing but it will help you go a lot faster.

I wanted a way to add stuff to my file quickly because I knew that I would be more likely to do it if it were easier. This led to the AutoHotKeyShortcutAppender, which is a small console app that takes in two arguments: the key combination for a macro and the output. Now I can hit Windows-Q to bring up SlickRun and type “asc scn] SomeClassName” and instantly it adds the macro to the end of my AHK file and reloads it. (If you use the code, you have to edit the app.config file and set the path to your AHK file.)

Have any other AHK favorites? Please post a comment and let me know!


  1. Aside from some similar to yours, 2 of my favorites are toggling AlwaysOnTop, and Win+LEFT and Win+RIGHT to move my window left or right one monitor.

    WinSet, AlwaysOnTop, Toggle,A

    I use this constantly. I like to pin a notepad or browser while I have a maximized IDE behind it, or pin a command line while I’m doing some IronRuby scripting, or a number of other things.

    WinGet, mm, MinMax, A
    WinRestore, A
    WinGetPos, X, Y,,,A
    WinMove, A,, X-A_ScreenWidth, Y
    if(mm = 1){
    WinMaximize, A

    WinGet, mm, MinMax, A
    WinRestore, A
    WinGetPos, X, Y,,,A
    WinMove, A,, X+A_ScreenWidth, Y
    if(mm = 1){
    WinMaximize, A

    It will restore a window if maximized, then re-maximize it on the other monitor after you move it.

    Andy Vulhop — September 7, 2010 @ 11:34 am

  2. Oh, and since my current client pushes all internet traffic through a proxy:

    ::igem install::igem install –http-proxy

    It’s nice so that I don’t have to remember the proxy every time.

    Andy Vulhop — September 7, 2010 @ 11:36 am

  3. Thanks for the tips
    I like the first 2 – single instance and set key delay
    I have a quite extensive list of sutocorrections and key remaps but I hadnt seen those too before
    PS – found you post via Twitter retweet by AHK bot

    Noblejoker — September 7, 2010 @ 11:40 pm

  4. Oooo Nice Article. It’s not often you see AHK getting some credit, and god knows it deserves it.

    Lemme throw you a few things, For starters, fundamentals

    ^!+#1:: Run C:\Program Files (x86)\AutoHotkey\AutoHotkey.chm
    Reload ; Assign a hotkey to terminate this script.
    Run d:\my dropbox\
    Run C:\Windows\SysWOW64\cmd.exe

    This way, if I want to quickly edit the AHK file I have current in the works. Since I generally reach for AHK before I go for any other programming language. It is sort of essential to quick operation.

    Another personal favorite of mine is the doubleclick, it adds an entirely new way of accessing things. For example, hitting escape twice shuts down a program, or double-clicking the Forward button on the mouse closes tabs.

    ; Double Click Escape Close Application
    if (A_PriorHotkey “~Escape” or A_TimeSincePriorHotkey > 300)
    ; Too much time between presses, so this isn’t a double-press.
    KeyWait, Escape

    Send !{F4}
    Sleep 1000

    Lastly, I also occationally use AHK for rapid data aggrigation, especially when I do not want to put in the effort to write things out by hand. I write XML files using the clipboard for example.

    WinGetActiveTitle, Title
    clipboard =
    SendInput ^c
    clipwait 1
    If Errorlevel = 0
    StringReplace, clipboard, clipboard, `r`n, , All
    MsgBox Done!

    ), D:\options.xml


    Anyway, thanks for the share. I enjoyed reading it. Hopefully some of this stuff may assist you as well. Cheers.

    Mr.Devlar — September 8, 2010 @ 12:18 am

  5. Other tips:

    Instead of “Send {Up}{Up}{Up}{Up}{Up}” you can write “Send {Up 5}.

    Also I saw you are using a lot of shortcuts like !^Up, !^Down …. It can be useful to use an Enterpad with AutoHotkey if you have too many shortcuts to remember:


    Sonia Lamarre — October 14, 2010 @ 12:06 pm

  6. Might I suggest using:

    Sleep 1000
    MsgBox 4, , Script reloaded unsuccessful, open it for editing?
    IfMsgBox Yes, Edit

    rather than Single Instance? This lets you reload your saved AHK script rather than having to double click it again to reload it. :)

    Jane Gray — November 16, 2011 @ 11:02 am

  7. [...] posted a few years back about some of the macros that I have in my AutoHotKey file. Since then I’ve added some new [...]

    More AutoHotKey goodness (database edition) « Jon Kruger's Blog — February 28, 2013 @ 9:13 am

Leave a comment

I have over 15 years of software development experience on several different platforms (.NET, Ruby, JavaScript, SQL Server, and more). I recognize that software is expensive, so I'm always trying to find ways to speed up the software development process, but at the same time remembering that high quality is essential to building software that stands the test of time.
I have experience leading and architecting large Agile software projects and coordinating all aspects of a project's lifecycle. Whether you're looking for technical expertise or someone to lead all aspects of an Agile project, I have proven experience from multiple projects in different environments that can help make your project a success.
Every team and every situation is different, and I believe that processes and tools should be applied with common sense. I've spent the last 10+ years working on projects using Agile and Lean concepts in many different environments, both in leadership roles and as a practitioner doing the work. I can help you develop a process that works best in your organization, not just apply a prescriptive process.
Have any questions? Contact me for more information.
Ditching the Office - How an everyday corporate development team turned into a remote working team
From Stir Trek 2018
From Stir Trek 2017, cbus.js 2017
Iteration Management - Your Key to Predictable Delivery
From Stir Trek 2016 and QA or the Highway 2015
From CodeMash 2016, QA or the Highway 2014, Stir Trek 2012
The Business of You: 10 Steps For Running Your Career Like a Business
From CodeMash 2015, Stir Trek 2014, CONDG 2012
From Stir Trek 2013, DogFoodCon 2013
(presented with Brandon Childers, Chris Hoover, Laurel Odronic, and Lan Bloch from IGS Energy) from Path to Agility 2012
From CodeMash 2012 and 2013
(presented with Paul Bahler and Kevin Chivington from IGS Energy)
From CodeMash 2011
An idea of how to make JavaScript testable, presented at Stir Trek 2011. The world of JavaScript frameworks has changed greatly since then, but I still agree with the concepts.
A description of how test-driven development works along with some hands-on examples.
From CodeMash 2010
From CodeMash 2010