Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

14 Handy AutoHotkey v2 Scripts for Everyday Windows Tasks

Copy ready-to-use AutoHotkey v2 examples for app launchers, clipboard-safe text shortcuts, audio controls, and window management.

Table of Contents

AutoHotkey v2 can turn a key combination into an app launcher, a text shortcut, or a window command. Start with one or two scripts you will use often. Save the examples you want in a text file ending in .ahk, with #Requires AutoHotkey v2.0 at the top. Open it using AutoHotkey v2 and use its tray icon to reload or exit. Each example below uses v2 syntax.

1. Search Google for selected text

Select a word or phrase and press Ctrl+Shift+S. The script temporarily copies the selection, restores the clipboard, and URL-encodes the text before opening the default browser. Use it only for text you are comfortable sending to a search engine.

^+s:: {
    previous := ClipboardAll()
    A_Clipboard := ""
    try {
        Send("^c")
        if !ClipWait(1)
            return
        query := Trim(A_Clipboard)
    } finally {
        A_Clipboard := previous
    }
    if query != ""
        Run("https://www.google.com/search?q=" . EncodeQuery(query))
}

EncodeQuery(text) {
    size := StrPut(text, "UTF-8")
    bytes := Buffer(size)
    StrPut(text, bytes, "UTF-8")
    result := ""
    Loop size - 1 {
        byte := NumGet(bytes, A_Index - 1, "UChar")
        char := Chr(byte)
        result .= RegExMatch(char, "^[A-Za-z0-9._~-]$") ? char : Format("%{:02X}", byte)
    }
    return result
}

2. Request a normal close for the active window

Ctrl+Alt+K sends the active app a close request, so it can ask about unsaved work. If the app is truly frozen, use Task Manager to identify it before ending the process.

^!k::WinClose("A")

3. Toggle system audio mute

Ctrl+Alt+M toggles speaker or headphone output. This is separate from muting your microphone.

^!m::Send("{Volume_Mute}")

14 AutoHotkey scripts you can use every day Picture 1

4. Use Caps Lock as Left Ctrl

This remap applies while the script is running. Shift+Caps Lock can still toggle Caps Lock. See other Caps Lock remapping ideas.

CapsLock::LCtrl
+CapsLock::SetCapsLockState(!GetKeyState("CapsLock", "T"))

5. Launch Notepad

Press Ctrl+Alt+N. Substitute another executable or an exact path if the application is not on the system path.

^!n::Run("notepad.exe")

6. Open your Documents folder

Ctrl+Alt+D opens the Windows Documents location, including a redirected folder where supported.

^!d::Run(A_MyDocuments)

7. Jump to the address bar in File Explorer

Ctrl+Alt+H focuses the address bar only when a File Explorer window is active. To see hidden items, use Explorer’s own View menu.

#HotIf WinActive("ahk_class CabinetWClass")
^!h::Send("^l")
#HotIf

8. Type an email address

Replace the example address. Type ;mail followed by a space to expand it. Avoid putting passwords or tokens in a script.

::;mail::you@example.com

9. Insert a short email signature

Type ;sig followed by a space in a message editor. Test it in a draft and adjust the line breaks if needed.

::;sig::Best regards,{Enter}Your name

10. Insert a local timestamp

Type ;stamp followed by a space to insert the date and time in a sortable format.

::;stamp::{
    SendText(FormatTime(A_Now, "yyyy-MM-dd HH:mm"))
}

14 AutoHotkey scripts you can use every day Picture 2

11. Correct a typo you make frequently

Add one hotstring per typo. The replacements apply anywhere the script can capture typing, so check that they do not interfere with code or identifiers.

::teh::the
::recieve::receive

12. Snap the current window left or right

These hotkeys invoke the built-in Windows Snap shortcuts. Release the trigger keys before the script sends the Windows key combination.

^!Left::SnapWindow("Left")
^!Right::SnapWindow("Right")

SnapWindow(direction) {
    KeyWait("Ctrl")
    KeyWait("Alt")
    Send("#{" . direction . "}")
}

14 AutoHotkey scripts you can use every day Picture 3

13. Move the active window to another monitor

Ctrl+Shift+W sends the Windows shortcut for moving a window to the display on the right. Change Right to Left to reverse the direction.

^+w::{
    KeyWait("Ctrl")
    KeyWait("Shift")
    Send("#+{Right}")
}

14. Capitalize the first letter of selected text

Ctrl+Alt+C lowercases a selected phrase and capitalizes its first character. This is useful for an all-caps heading. It does not preserve formatting, proper names, or capitalization inside the phrase. Try it first in a plain-text editor.

^!c:: {
    previous := ClipboardAll()
    A_Clipboard := ""
    try {
        Send("^c")
        if !ClipWait(1)
            return
        text := StrLower(A_Clipboard)
    } finally {
        A_Clipboard := previous
    }
    if text != ""
        SendText(StrUpper(SubStr(text, 1, 1)) . SubStr(text, 2))
}

Follow each example’s shortcut label when testing. Change any combination already used by your browser or editor. If an app runs with administrator privileges, a normal AutoHotkey script may not be able to send input to it. Test the scripts in a standard app such as Notepad first.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.