Here are some AutoHotkey scripts written in AHK v2.
The script showcase contains a mix of custom shortcut keys and text replacement intended to perform useful tasks, execute commonly used commands and run several small functions.
Suggestions for improving the script code are welcome.
Link to all-in-one script.
Last updated - 2024.11.29
Click on ⏵ to show/hide some of the descriptions.
Set the default state of CapsLock
, NumLock
and ScrollLock
to On or Off when the script runs.
Add this script to your system startup and set the lock-state automatically after login.
Show/Hide
Show/hide protected operating system (OS) files in Windows File Explorer from the script's tray menu, as an alternative to navigating and changing Explorer's Folder Options.
The script checks the current state of the setting on start using Windows Registry and shows a handy check mark in the tray menu when the option to display protected OS files is enabled.
View code that changes the script's tray icon. This automatically also changes the default icon in a script's error windows, msg boxes and GUI title icon.
To demonstrate the use of an external icon file for this purpose, a few icon files are included in the /icons/Tray/ folder.
Two Numpad keyboard shortcuts, one to check the script's recent actions using ListLines
, and another to Reload
the script.
Show/Hide
See several examples of how to disable hardware keys that you don't use or trigger accidentally too often, or repurpose the function of such keys to your needs -
- Disable the
Insert
key from accidentally triggering when you are trying to press adjacent keys likeDelete
orPause/Break
. - Prefer
Alt + Tab
over Task view? RemapWin + Tab
shortcut to always invoke the legacyAlt + Tab
menu. - Are you using a laptop and miss the
Page Up/Page Down/Home/End
buttons? Remap theRCtrl + Up/Down/Left/Right
button combos to regain the function of the missing keys. - Minimise a window instantly by pressing
ALT + M
, instead of moving your mouse cursor to the title bar to click on the "Minimise" button.
Show/Hide
Do you accidentally trigger CapsLock
when trying to press A
or Shift
or Alt + Tab
?
Do you want to enable CapsLock briefly and have it automatically turn off after 10 seconds?
This script can help you do the following -
- Disable the
CapsLock
key to prevent it from accidentally turning ON. - Hit the
Shift + CapsLock
keys to turn ON CapsLock-state for a customisable duration (10 seconds by default, but can range from 250 milliseconds to 49 days). - Add a quiet notification in the corner when CapsLock is ON and dismiss it automatically once CapsLock is off.
- If CapsLock is ON, turn it off instantly by hitting the
Esc
key or theCapsLock
key (even if CapsLock is remapped to never turn ON).
Show/Hide
Use Win + Numpad 1-9
keys to move your mouse pointer with precision, pixel by pixel, using AHK's built-in MouseMove
command.
Customise the MouseMove
command to your needs by altering one or more of the following -
- Starting coordinates (absolute or relative position on screen, app window or client)
- Speed of mouse cursor [range of 0 (fastest, instant), 2 (default) or 100 (slowest)]
- Degree of mouse movement (change in absolute/relation position by a precise number of pixels)
Show/Hide
View three methods to close or kill an app or window -
- Send
WinClose
command withAlt + Right Click
- closes any app or window instantly without having to navigate to the 'Close' button in the title bar. This simulates the defaultAlt + F4
behaviour (in most apps) or theCtrl + W / Q
action (available in some apps).
Annoyed by an unresponsive window? Instead of opening Task Manager, try this first -
- Send
WinKill
command withCtrl + Alt + F4
- kill the unresponsive window forcefully by terminating its process.
Didn't work? Kill all instances of an app -
- Send
ProcessClose
command withCtrl + Alt + Shift + F4
- The script shows a warning, with window titles of visible and hidden windows of the unresponsive process and asks for confirmation before terminating the process.
Show/Hide
Here is a handy way to work with multiple windows on your PC.
- Use mouse keys
Ctrl + Shift + Wheel Up/Down
to increase/decrease the transparency of an app or window. Transparency values range from1
(invisible) to255
(opaque) and mouse keys increase/decrease transparency value by 20 (customisable - see variableTrans +
andTrans -
). - Quickly set the transparency of an app or window to pre-defined levels in two key presses - Hit
F8
and select an option1 to 5
from the pop-up menu.
Show/Hide
Do you find yourself opening the Recycle Bin multiple times?
Do you want to avoid minimising all windows to go to the desktop or scrolling the navigation pane to find the Recycle Bin icon?
Here is a single shortcut Ctrl + Delete
that will allow you to do the following -
- Open the Recycle Bin when Explorer is not open, or
- Navigate to the Recycle Bin when Explorer is open, or
- Bring the Recycle Bin Explorer window in the background to the foreground, or
- Empty the bin when the Recycle Bin Explorer window is in the foreground.
Alternatively, assign one or more of these actions to various keyboard shortcuts. AutoHotkey is awesome like that :)
Use a keyboard shortcut Ctrl + Esc
to turn off your monitor.
Show/Hide
Add items missing in the Win + X
menu to a customisable pop-up menu triggered by Win + Shift + X
.
Show/Hide
Change any length of text to lower, UPPER, Sentence, Title or iNVERT
case, in-line through a pop-up menu using a single keyboard shortcut.
This section of the script works with special characters such as é → É
and  → â
and is Unicode compatible. Search for TestString
in the script for a more comprehensive example.
Show/Hide
Enclose words and numbers in different types of quotation marks or symbols '',"",(),[],{},``,%%,‘’,“”
in-line using a pop-up menu & shortcut keys.
This section of the script allows you to switch the positions of two characters by placing the text cursor (|
) between them and pressing a keyboard shortcut ALT + L
.
The letters reverse positions - ab|c
becomes ac|b
.
Keyboard shortcut ALT + T
enables you to keep a specified window on top of all other windows (except other always-on-top windows) and toggle it back to normal.
Show/Hide
Here are some examples of the wide breadth of uses for the AutoHotkey hotstrings feature.
- Find & replace text in Clipboard with and without regular expressions(RegEx).
- Trim clipboard text - remove tabs (
\t
), newline markers (\r \n
) and double spaces (\s+
or " - Type the current date and/or time in your preferred format, regional or otherwise.
Show/Hide
Create keyboard shortcuts and text replacement commands tailored to specific windows or apps using the #HotIf
command. This section of the script includes useful examples of shortcuts for Firefox, Telegram and Windows Explorer.
- Firefox
- Hit
Ctrl + Shift + O
to open library / bookmark manager. - Don't want to accidentally exit the browser with the
Ctrl + Shift + Q
shortcut? Disable it.
- Hit
- Windows Explorer
- Change action of
F1
(opens Help in Edge Browser) toF2
(rename command). - Hit
Ctrl + Shift + A
to unselect file(s)/folder(s). Conveniently map the opposite of the default behaviour ofCtrl + A
(select all) to a similar shortcut. - Copy the full path of one or more folder/file(s) to the clipboard using the shortcut
Ctrl + Shift + C
. - Copy folder/file name(s) without their path to the clipboard using the shortcut
ALT + N
. - Copy file name(s) without their extension and path to the clipboard using the shortcut
Ctrl + ALT + N
.
- Change action of
Do you find it annoying to correct the capitalisation of the first letter of every sentence while writing?
This script does it so seamlessly that you might not even notice. The script auto triggers in-line after every Enter (⏎) NumpadEnter (⏎) dot (.) exclamation (!) and question (?) mark
.
Whether you have a mouse with or without a tilt wheel, some applications refuse to scroll horizontally.
Here are five methods that simulate tilt wheel actions and force even the most recalcitrant windows to scroll sideways.
Show/Hide
Windows File Explorer prevents users from adding certain symbols \/:*?"<>|
in a file name.
This script allows you to insert similar Unicode symbols as replacements, organically and automatically as you type.
Create a personalised alert programmed in AHK v2 that replaces the depreciated Progress
command from AHK v1.
The alert uses the GUI()
function and allows you to customise the notification's text, duration and position
.
Alternatively, a similar use of ToolTip
is also included.
Link to standalone script.
Last updated - 2024.11.29
This script was created as a rudimentary alternative to PhraseExpress's clipboard management feature with inspiration from several v1 scripts.
The script does the following -
- Clipboard array (
ClipArr
) contains 25 slots that automatically save text1 when Windows Clipboard is used. The number of slots is customisable to any number (see variableLimitClipArr
). - Hitting
^x
(Ctrl + X
/ Cut) or^c
(Ctrl + C
/ Copy) triggers script'sOnClipboardChange
function and saves text to a slot inClipArr
. - Hitting
^x
or^c
a second time moves previously saved text to the next slot and copies the newly selected text to the first slot. - This behaviour continues until the 25 slots are filled, after which, when new text is added to
ClipArr
on the 26th occasion or later, the oldest copied text (now in the 25th slot) is lost. - To view text saved in any of the slots, type
c++
to bring up a pop-up menu. Use any one of the shortcuts2 to retrieve text from the corresponding slot. - Retrieve text directly from a slot using hotstring
v{slot-number}+
. For example, from the test array3, typingv2+
retrievesSlot 2 Shortcut 2
andv25+
retrievesSlot 25 Shortcut g
. - Retrieve text from multiple slots using hotstring
c{slot-numbers}+
. For example, from the test array, typingc2+
retrieves text from slots 1 & 2 andc10+
retrieves text from slots 1 through 10. ClipArr
slots persist between restarts, unlike Windows Clipboard. Slot contents are saved to a file upon script exit and loaded back from the file when the script starts.- Old script contents can be retrieved by restoring
ClipArrFile.txt
from Recycle Bin.
Footnotes
-
Saves only text - this includes anything from the clipboard that can be expressed as text, such as filenames (with full path) when files/folders are copied from a Windows File Explorer window via
Ctrl + C
orCtrl + X
. See script\Showcase.ahk
for examples that show you how to copy the full path with or without file extension and path. ↩ -
Shortcuts correspond to the number/alphabet/symbol before
→
. Shortcuts are usually underlined and consist of numbers from number row, and letters from the rows below it in a QUERTY keyboard. Customise the shortcut characters and their order by altering the characters inClipShortcuts
variable as needed. ↩ -
Test array with 25 slots containing alphanumerical text
ClipArr := ["Slot 1 Shortcut 1", "Slot 2 Shortcut 2", "Slot 3 Shortcut 3", "Slot 4 Shortcut 4", "Slot 5 Shortcut 5", "Slot 6 Shortcut 6", "Slot 7 Shortcut 7", "Slot 8 Shortcut 8", "Slot 9 Shortcut 9", "Slot 10 Shortcut 0", "Slot 11 Shortcut Q", "Slot 12 Shortcut w", "Slot 13 Shortcut e", "Slot 14 Shortcut r", "Slot 15 Shortcut t", "Slot 16 Shortcut Y", "Slot 17 Shortcut u", "Slot 18 Shortcut i", "Slot 19 Shortcut o", "Slot 20 Shortcut P", "Slot 21 Shortcut a", "Slot 22 Shortcut s", "Slot 23 Shortcut d", "Slot 24 Shortcut f", "Slot 25 Shortcut G"]
. ↩