Skip to content

AutoHotkey scripts with several small functions and shortcut keys, written in AHK v2.

License

Notifications You must be signed in to change notification settings

xypha/AHK-v2-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AHK v2 scripts

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.

\Showcase.ahk

Link to all-in-one script.
Last updated - 2024.11.29

Contents

Click on ⏵ to show/hide some of the descriptions.

Set default state of Lock keys

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 OS files

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.

Show/Hide OS files

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.


Tray Icon

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.


Check & Reload AHK

Two Numpad keyboard shortcuts, one to check the script's recent actions using ListLines, and another to Reload the script.


Remap Keys

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 like Delete or Pause/Break.
  • Prefer Alt + Tab over Task view? Remap Win + Tab shortcut to always invoke the legacy Alt + Tab menu.
  • Are you using a laptop and miss the Page Up/Page Down/Home/End buttons? Remap the RCtrl + 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.

Customise CapsLock

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 the CapsLock key (even if CapsLock is remapped to never turn ON).

Move Mouse Pointer pixel by pixel

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)

Close or Kill an app window with shortcuts

Show/Hide

View three methods to close or kill an app or window -

  • Send WinClose command with Alt + Right Click - closes any app or window instantly without having to navigate to the 'Close' button in the title bar. This simulates the default Alt + F4 behaviour (in most apps) or the Ctrl + W / Q action (available in some apps).

Annoyed by an unresponsive window? Instead of opening Task Manager, try this first -

  • Send WinKill command with Ctrl + Alt + F4 - kill the unresponsive window forcefully by terminating its process.

Didn't work? Kill all instances of an app -

  • Send ProcessClose command with Ctrl + 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.

Kill All Instances Of An App


Adjust Window Transparency

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 from 1 (invisible) to 255(opaque) and mouse keys increase/decrease transparency value by 20 (customisable - see variable Trans + and Trans -).
  • Quickly set the transparency of an app or window to pre-defined levels in two key presses - Hit F8 and select an option 1 to 5 from the pop-up menu.

Adjust Window Transparency


Recycle Bin shortcut

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 :)


Display Off shortcut

Use a keyboard shortcut Ctrl + Esc to turn off your monitor.


Add Control Panel Tools to a Menu

Show/Hide

Add items missing in the Win + X menu to a customisable pop-up menu triggered by Win + Shift + X.

Control Panel Tools Menu


Change Text Case

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.

Change the case of text


Wrap Text In Quotes or Symbols

Show/Hide

Enclose words and numbers in different types of quotation marks or symbols '',"",(),[],{},``,%%,‘’,“” in-line using a pop-up menu & shortcut keys.

Wrap Text In Quotes or Symbols


Exchange adjacent letters

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.


Toggle Window On Top

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.


Process Priority

Show/Hide

Hit Win + P to select and change the priority level of a process.

Set Priority


Use cases for Hotstrings

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 " ") with or without RegEx.
  • Type the current date and/or time in your preferred format, regional or otherwise.

Use cases for #HotIf

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.
  • Windows Explorer
    • Change action of F1 (opens Help in Edge Browser) to F2 (rename command).
    • Hit Ctrl + Shift + A to unselect file(s)/folder(s). Conveniently map the opposite of the default behaviour of Ctrl + 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.

Capitalise the first letter of a sentence

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.


Horizontal Scrolling

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.


Symbols In File Names

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.

Symbols In File Names


Notification Function

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.


MultiClip

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 variable LimitClipArr).
  • Hitting ^x (Ctrl + X / Cut) or ^c (Ctrl + C / Copy) triggers script's OnClipboardChange function and saves text to a slot in ClipArr.
  • 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, typing v2+ retrieves Slot 2 Shortcut 2 and v25+ retrieves Slot 25 Shortcut g.
  • Retrieve text from multiple slots using hotstring c{slot-numbers}+. For example, from the test array, typing c2+ retrieves text from slots 1 & 2 and c10+ 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

  1. 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 or Ctrl + X. See script \Showcase.ahk for examples that show you how to copy the full path with or without file extension and path.

  2. 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 in ClipShortcuts variable as needed.

  3. 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"].

About

AutoHotkey scripts with several small functions and shortcut keys, written in AHK v2.

Topics

Resources

License

Stars

Watchers

Forks