Skip to content

cbaoth/AutoHotkey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoHokey Scripts

AutoHotkey.ahk

Source: AutoHotkey.ahk

Core AHK script.

All included scripts assume the following parameter settings:

SetTitleMatchMode, RegEx ; Match window names, ahk_class, ahk_exec, etc. using regex

All AHK scripts listed below are included (referenced) in this core script. In addition the following key-bings are defined (excerpt):

Active Key Action Description

ok

Win-Return

Open Terminal

Runs one of (first available): Terminus, Hyper, ConEmu, Powershell (open home directory).

ok

Win-Shift-Return

Run Powershell as Admin

Runs Powershell as Administrator.

ok

Win-F1-4

SSH

Focus / launch various SSH sessions (KITTY).

ok

Win-b

Browser

Focus / launch browser (Chrome).

ok

Win-e (US: k)

Editor

Focus / launch editor (VS Code).

ok

Win-Shift-e (US: K)

Paste to Editor

Copy selection, paste into editor (newline), and switch back to original window.

ok

Win-m

Mail

Focus / launch mail client (Outlook).

ok

Win-w

Web Search

Web search for current text selection.

ok

Win-Shift-f (US: e)

Explorer

Windows "Explorer" Run window explorer (default: Win-e). Default bindings disabled.

ok

Win-Shift-s (US: d)

Show Desktop

Windows "Show Desktop" (default: Win-d). Default bindings disabled.

ok

Win-Shift-r (US: s)

Run

Windows "Run Dialog" (default: Win-r). Default bindings `Win-s `(US: r) disabled, starts Keypirinha instead (app setting).

ok

Win-F9

Move Window

Move active window to 100x100 of second screen.

ok

Win-LeftAlt-F9

Move Window

Move active window negative by window decoration (center window content, e.g. hide decoration for game in windowed mode).

KeyMap.ahk

Source: KeyMap.ahk

Some basic key(re-)maps. Note that my default keyboard layout is Colemak:

colemak layout

Keybiding excerpts (some disabled in my current setup):

Active Key Action Description

ok

XButton1 (Mouse 4)

PageUp

Faster paging than mouse-wheel. Replaces prev./next (usually useless) binding.

ok

XButton2 (Mouse 5)

PageDown

See above …​

ok

Win-Alt-Space

MediaKey: Pause

Easier media key access (also useful if dedicated keys not available).

ok

Win-Alt-Up/Comma

MediaKey: Previous Track

See above …​

ok

Win-Alt-Down/Period

MediaKey: Next Track

See above …​

ok

Win-Alt-0

MediaKey: Toggle Mute

See above …​

ok

Win-Alt-Dash (-)

MediaKey: Lower Volume

See above …​

ok

Win-Alt-= (+)

MediaKey: Raise Volume

See above …​

ok

Win-x, Win-c

Close current window

Same as Alt-F4

ok

Win-x, Win-k

Kill current window (process)

Easily kill app if not responding

ok

Alt/Shift-ScrollLock

Toggle CapsLock

Noone really needs CapsLock nowadays but sometimes it is activated for no apparent reason, so it’s good to have a key-binding to deactivate it.

ok

SC056 (DE: <>|)

Control

If, for some strange twist of faith, I’m forced to use a german QWERTZ keyboard, the otherwise useless <>| key will be re-mapped to Control.

close window

[ ]

( )

Classic lisp hacker / emacs mapping, but also practical in daily life, since ( ) is more commonly used than [ ] even though dedicated keys exist for the latter.

ok

AltGr-n/e

( )

Home-row access to brackets (j/k on US layout).

ok

AltGr-N/E

[ ]

Home-row access to brackets (J/K on US layout).

ok

AltGr-i/o

{ }

Home-row access to brackets (l/; on US layout).

Additional (currently disabled) mappings exist for:

  • German umlauts accessible on default german keyboard positions + AltGr (e.g. AltGr-;ö) or like on common international layout (AltGr) position (e.g. AltGr-pö).

    • The latter is already the case with the international US Colemak layout.

  • CapsLockBackspace

    • Already default with Colemak layout (partially not the case in the past).

  • CapsLockControl

    • Old hacker mapping (e.g. from emacs users) but no longer preferred by me. Ctrl already easily accessible but backspace requires leaving home-row, so I prefer backspace instead.

WindowTracking.ahk

A script that tracks window details, like window id, class, process id, process executable and process name, in global variables allowing visualization in a tooltip and copy-to-clipboad. Intended to be used as a Windows / AutoHotkey development tool.

By pressing Win-F8 the mouse cursor monitoring mode is activated. While active, a tooltip like the following will be shown and updated whenever the mouse cursor focuses on a new window:

windowtracking tootlip 1

Instead of following the mouse cursor it’s also possible to update the tooltip whenever the active window changes (e.g. on alt-tab).

The script includes a blacklist that ignores windows like windows task-bar/-choose, desktop, the AHK tooltip itself and other windows that usually doesn’t want to capture. These blacklisted windows are still captured, but in a separate set of variables (single last blacklisted window only).

By pressing Win-Shift-F8 the active window monitoring mode is activated, additionally showing details of the last blacklisted window:

windowtracking tootlip 2

The hotkeys Win-(Alt-)F8 toggle the tooltip (on/off). While active the tooltip will update either every time the mouse curser hovers above a new window (Win-F8, track_active = false) or whenever a new window is activated (Win-Alt-F8, track_active = true).

; win-F8 -> toggle mouse hover tooltip without blacklisted windows
#F8::_toggleShowTrackedWindows() ; clipboard on close, show final tt 5sec
;#F8::_toggleShowTrackedWindows(,,0,0) ; no clipboard, close immediate
;#F8::_toggleShowTrackedWindows(,,2) ; always clipboard (each change)

; win-shift_F8 -> toggle active window tooltip with blacklisted windows
#+F8::_toggleShowTrackedWindows(true, true) ; bl + clipboard on close, show final tt 5sec
;#+F8::_toggleShowTrackedWindows(true, true, 0, 0) ; bl + no clipboard, close immediate
;#F8::_toggleShowTrackedWindows(true, true, 2) ; bl + always clipboard (each change)

Per default the tooltip content is copied to the clipboard when monitoring is stopped (toggle off). Alternatively it is possible to continuously update the clipboard (on every window change) or to not update the clipboard at all. See the code documentation of _toggleShowTrackedWindows and the examples above.

The clipboard text contains the same information as the tooltip but in a slightly simplified/cleaner format using \t as column delimiter:

ACTIVE WINDOW:

 

active_id

0x831b5a

active_title

README.adoc - dotfiles - Visual Studio Code

active_class

Chrome_WidgetWin_1

active_pid

343836

active_procname

Code.exe

PREVIOUS WINDOW:

 

previous_id

0xd61bb4

previous_title

AutoHotkey Community - Index page - Firefox Developer Edition

previous_class

MozillaWindowClass

previous_pid

172388

previous_procname

firefox.exe

XMouseClipboard.ahk

This script tries to provide the "copy on selection" and "middle-click paste" features known from X Windows.

Middle-click Paste

Allows middle-click (MButton) paste in most apps, with "click-through" (~) support (for apps that treat middle-click in a special way, e.g. navigation in 3D/CAD apps), and special rules for individual apps like e.g. KITTY/Putty/Firefox (MButton paste configurable) or common terminals (Ctrl-Shift-v).

Key Function

MButton

Paste text into the current app (key binding depending on app, default Ctrl-v, terminals usually Ctrl-Shift-v, etc.)

Shift-MButton

Same as above but enclose the pasted text into double-quotes "{Clipboard}".

Copy on Selection

This one is a bit tricky. For now the script is not able to identify whether a text window / editor is active (with a text selection) or not. It is only able to identify that a drag action was performed with the mouse. Since there are any number of possible drag actions that could be performed, intentionally (e.g. drag-drop file) or unintentionally (e.g. drag slightly when clicking an action button) this approach is not very reliable. In addition, in many cases it is not desired that a selected text is automatically copied to the clipboard (e.g. select text to override / compare it with the clipboard content). That’s why this feature is currently disabled (in my scripts), it would need additional work an restrictions (e.g. terminal windows only) to be usable in an acceptable manner. Since most windows terminals already support copy on selection out of the box, there is currently no immediate need for this feature.

ConfineMouse.ahk

This scripts confines the mouse to a window’s screen area, either of the window currently below the mouse cursor (default) or the active window. The confinement area can optionally be reduced by a fixed margin to exclude the window decoration.

Mouse cursor confinement is sometimes desired when working in a mouse-heavy application or games (e.g. in windowed mode), especially in a multi-screen environment. The scripts helps avoiding exiting the working area and prevent unwanted clicks (e.g. taskbar, different app, etc.).

Key Function

Win-F11

Toggle window confinement to the window currently below the mouse cursor with a fixed margin, excluding the window decoration.

Win-Alt-F11

Same as above but confined to the full window size, include decoration.

SendToWindow.ahk

This script sends a sequence of keys to the current window (optional), switches to a target window, sends another key sequence (optional), and finally switches back to the previous window.

Key Function

Win-Alt-e

Copy (text only) to clipboard, switch to code editor, paste text switch back.

Win-Alt-Shift-e

Copy (text only) to clipboard, switch to code editor, press End, Return, Home (add newline, home to avoid auto-indent) and paste text.

Win-Alt-;

Switch to mpv/netflix/youtube an pause playback (using space)

The following (configurable) steps are executed in sequence:

  • Optionally clear the clipboard (clipboard_mode > 0)

  • Optionally send a series of keys (source_keys) to the active window

  • Optionally wait for the clipboard (clipboard_mode > 0)

  • Optionally stop if clipboard dose contain something other than text (clipboard_mode == 0)

  • Switch to the target_window

  • Optionally send a series of keys (target_keys) to the target window

  • Switch back to the previously active window

Hotkey Examples

Note that the default parameters are set to copy text only (clipboard_mode = 1) using Ctrl-c (source_keys = "^c") and Ctrl-v (target_keys = "^v").

;; copy text only to Notepad++ (no fancy stuff)
_sendToWindow("ahk_class i)^Notepad\+\+$")

;; copy text only to emacs using Ctrl-y to paste
_sendToWindow("ahk_class i)^Emacs$",, "^y")

;; switch to mpv/netflix/youtube an pause playback (using space)
_sendToWindow("^(.* mpv|Netflix .*|.* YouTube .*)$", "", "{Space}", 0)

;; copy to KITTY SSH session (host 10.0.23.12) using Shift-Insert, finally press Return
_sendToWindow("i)10.0.23.12.*ssh.*Kitty",, "+{Insert}{Return}")

;; copy to WordPad into a new line and add newline after pasting, copy non-text too (e.g. images)
_sendToWindow("ahk_class WordPadClass",, "{End}{Return}^v{Return}", 2)

Games

Some game specific hotkeys and functions.

Path of Exile

Source: PathOfExile.ahk

Requires functions from Commons.ahk

Key Function

` (hyphon)

Panic button. Use all flasks in random order with random intermittent delay.

ctrl-h

Enter the hideout (if possible, e.g. from cities/camps).

Skyrim

Source: Skyrim.ahk

Key Function

Win-[

Load Riften Honeyside house using console command (considered a cheat, no official fast travel)

Win-]

Load Riften Thieves Guild Headquarters using console command (considered a cheat, no official fast travel)

Divinity Original Sin

Source: Divinity.ahk

Diablo III

Source: Diablo3.ahk

Diablo II Resurrected

Grim Dawn

Source: GrimDawn.ahk

Appendix

Icon pack by Icons8

About

AutoHotkey scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published