Keyboard Script v2 is the next-generation iteration of input scripting languages designed to simulate keyboard strokes, mouse movements, and control sequences with high precision. Unlike simple key remappers, v2 introduces a more robust syntax, lower latency, and greater compatibility with modern operating systems.
At its core, Keyboard Script v2 allows users to write plain-text scripts that listen for specific triggers (hotkeys) and execute automated responses (actions). For example, you can program the Caps Lock key to act as a modifier, or create a script that types your email address whenever you press Alt + E.
While Keyboard Script v2 is incredibly powerful, remember:
Because Keyboard Script v2 can simulate any keystroke, it is a double-edged sword.
Once you understand the basics, Keyboard Script v2 shines in advanced scenarios.
(If you want, I can generate the JSON/YAML schema, example config file, or a prototype macro-engine design next.)
It sounds like you're looking for a comprehensive AutoHotkey (AHK) v2
script to enhance your keyboard functionality. Since v2 uses a more modern, function-based syntax compared to v1, it's a great choice for creating powerful, clean macros. keyboard script v2
Below is a "full piece" script that combines the most common productivity features into one file. 🛠️ Essential Keyboard Master Script (AHK v2) This script includes text expansion window management media controls custom hotkeys autohotkey
#Requires AutoHotkey v2.0 #SingleInstance Force
; ============================================================================== ; 📝 TEXT EXPANSION (Hotstrings) ; ============================================================================== ; Type the abbreviation and press Space/Tab to expand.
::@@::myemail@example.com ; Type @@ for email ::sig::Best regards,`nYour Name ; Type sig for multi-line signature ::dtt:: ; Type dtt for current date/time Send FormatTime(, "yyyy-MM-dd HH:mm")
; ============================================================================== ; 🪟 WINDOW MANAGEMENT ; ==============================================================================
; CapsLock + H: Minimize active window CapsLock & h::WinMinimize "A"
; CapsLock + F: Toggle Always-On-Top for active window CapsLock & f:: ExStyle := WinGetExStyle("A") if (ExStyle & 0x8) ; 0x8 is WS_EX_TOPMOST WinSetAlwaysOnTop 0, "A" ToolTip "Always-On-Top OFF" else WinSetAlwaysOnTop 1, "A" ToolTip "Always-On-Top ON" SetTimer () => ToolTip(), -1000 ; Clear tooltip after 1s Keyboard Script v2 is the next-generation iteration of
; ============================================================================== ; 🎵 MEDIA & VOLUME CONTROLS ; ============================================================================== ; Uses Ctrl + Arrow Keys for quick media control
^Up::Send "Volume_Up" ; Ctrl + Up: Vol Up ^Down::Send "Volume_Down" ; Ctrl + Down: Vol Down ^Left::Send "Media_Prev" ; Ctrl + Left: Previous Track ^Right::Send "Media_Next" ; Ctrl + Right: Next Track ^Space::Send "Media_Play_Pause" ; Ctrl + Space: Play/Pause
; ============================================================================== ; 🚀 LAUNCHERS & SYSTEM ; ==============================================================================
; Alt + N: Open Notepad !n::Run "notepad.exe"
; Alt + G: Search Google with selected text !g:: A_Clipboard := "" ; Clear clipboard Send "^c" ; Copy selection if ClipWait(2) Run "https://google.com" . A_Clipboard
; Ctrl + Alt + R: Reload this script (useful while editing) ^!r::Reload Use code with caution. Copied to clipboard 🚀 How to Use This Script Install AHK v2: Ensure you have the latest version from the AutoHotkey Official Site Create the File: Right-click your desktop, select New > AutoHotkey Script , and name it (e.g., Master.ahk Paste & Save: Right-click the file, select Edit with Notepad (or VS Code), paste the code above, and save.
Double-click the file. You will see a green "H" icon in your system tray. 💡 Quick Tips for v2 Functions are Key: Notice the use of braces and quotes . Unlike v1, almost everything in v2 is a function call. Case Sensitivity:
Because "Keyboard Script v2" could refer to a specific coding project, a log of a mechanical keyboard build, or a software update, I have drafted three different types of write-ups.
You can choose the one that best fits your needs.
The Script v2 is a massive upgrade over my first build. The aluminum case provides a resonant feedback that plastic cases simply can't match. The Oil Kings paired with the GMK caps create a sound profile that is deep and crisp.
Lessons Learned for v3: I might try a gasket-mounted case next time to add a bit more bounce/flex to the typing experience.
The biggest issue with legacy keyboard scripts (v1) was sloppy memory management. You would write a simple remap:
^!k:: Send, Hello World
It worked. But add 50 of these, plus a few SetKeyDelay commands, and suddenly your keystrokes would "hang" or paste into the wrong window. That might seem small
v2 fixes this. The new syntax forces explicit objects and functions. For example, the v2 equivalent is:
^!k::
Send("Hello World")
That might seem small, but it creates a true function boundary. When the hotkey ends, v2 cleans up everything. No more stuck modifier keys.