Skip to content
GitHub Twitter

Five AutoHotkey Scripts I Can't Live Without

It would be an understatement to say that I am a productivity and organization freak. If there's a way to make something more efficient or quicker, I'll obviously try to do so... almost obsessively. I have spreadsheets that track probably too many things and have optimized my workflow and experience through things such as completely changing a program's keyboard shortcuts, using a number pad on a second keyboard as a makeshift audio mixer, but most importantly: the use of AutoHotkey.

AutoHotkey has seriously made me more efficient and made everyday tasks more bearable, and is one of the pieces of software that I truly believe that everyone should learn. While the obvious use case is automating repetitive tasks, there are much smaller, more atomic, use cases which many people may have never thought of needing, but have become features that I cannot live without.

All scripts with sources in this post can be found in my ahk-scripts GitHub repository.

Basic Desktop and Virtual Desktop Management

On my primary keyboard, I have rebound Caps Lock to be a modifier key, similar to how Control, Alt, or Shift work with keyboard shortcuts. AutoHotkey scripts made with the Caps Lock modifier are targeted at my most used functions which can, more often than not, be activated with one hand.

#if (getKeyState("CapsLock", "P"))	
  *CapsLock::return

  ; Shortcuts here...
#if

Virtual Desktops on Windows are a lesser known feature to the average user, but play a vital role in many's everyday work, including mine. While there are shortcuts that allow you to create a new virtual desktop or move left or right to such, there is no keyboard shortcuts to move a window to a virtual desktop or navigate/skip through virtual desktops. Moreover, there is no way to move windows between desktops without using your mouse, so I add the following shortcuts:

  • Caps Lock + [1-9]: Skip to desktop [1-9].
  • Caps Lock + Alt + [1-9]: Move the current window to desktop [1-9] without changing desktops.
  • Caps Lock + X: Move the current window to the previous virtual desktop, and switch to that desktop.
  • Caps Lock + C: Move the current window to the next virtual desktop, and switch to that desktop.

Additionally, I add the following shortcuts that rebind already existing shortcuts to use the Caps Lock modifier.

  • Caps Lock + Q: Minimize the current window.
  • Caps Lock + W: Maximize the current window.
  • Caps Lock + S: Move the current window one monitor to the left, looping.
  • Caps Lock + D: Move the current window one monitor to the right, looping.
#if (getKeyState("CapsLock", "P"))	
  Q::WinMinimize, A
  W::Send #{Up}
  S::Send +#{Left}
  D::Send +#{Right}
#if

This combination of shortcuts allows me to manage the windows across my virtual desktops quickly in 95% of cases.

Quickly Trim Videos

One task that AutoHotkey greatly reduced the time it took was trimming videos. Previously where I needed to import a video into a video editor, trim it, and export it with the correct settings, can be done with AutoHotkey using ffmpeg behind the scenes.

I can simply point to a video or audio file, tell it where to output the trimmed file, and provide in and out points in either seconds (24, 45, ...) or timestamps (1:23, 5:25, ...).

This has greatly saved me time where I need to share a specific segment of media, often lasting a couple seconds, pulled from a much longer source.

Instant Color Picker

Gone are the days of importing a screenshot into paint.NET and using the color picker to get a color on your screen with this one.

getColorAtCursor() {
  MouseGetPos x, y
  PixelGetColor color, %x%, %y%, RGB
  
  color := SubStr(color, 3)
  color := "#" color

  StringLower, color, color

  return color
}

This function returns the color under the cursor. In combination with other scripts, I have it implemented such that the found color is briefly shown on screen for 500ms and is copied to the clipboard for convenient use.

Instant Folder Access

While very simple, binding keys to open some of my most used folders has been a huge time saver.

; Bound to the arrow keys on my second keyboard.
Up::Run, E:\0. Media Pool
Left::Run, C:\Users\Hunter\Desktop
Down::Run, C:\Users\Hunter\Downloads
Right::Run, C:\Users\Hunter\Documents

Multiple Clipboards

Having multiple keyboards has saved me a lot of time in situations when I'm copying multiple instances of text or need reference to multiple items. While having three clipboards have fit most of my use cases, having more wouldn't hurt.

copy(clipboardID) {
  global
  local oldClipboard := ClipboardAll

  Clipboard =
  Send ^c

  ClipWait, 2, 1
  if(ErrorLevel) {
    Clipboard := oldClipboard
    return
  }

  ClipboardData%clipboardID% := ClipboardAll

  Clipboard := oldClipboard
}

paste(clipboardID) {
  global
  local oldClipboard := ClipboardAll

  Clipboard := ClipboardData%clipboardID%
  Send ^v

  Sleep 100

  Clipboard := oldClipboard
  oldClipboard = 
}

Honorable Mentions

  • Toggle window opacity between 100%, 75%, and 50%.
  • Toggle the current window to be "Always on Top".
  • Select files in Explorer by RegEx.
  • Rename files in Explorer by RegEx.
  • Copy path of selected file in Explorer.
  • Instant notepad.exe.
  • Instant date and instant time.