Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autohotkey: Require Capslock for Hotstring

The following autohotkey code

:*:\alpha::α

results in the hotstring text "\alpha" being continuously replaced by the corresponding UTF8 char "α".

However, it would be quite annoying to always have this replacement enabled. So I figured to activate it via the CapsLock key. So how do I enable the above hotstring only when the CapsLock key was pressed immediately before the string combination?

like image 565
logical x 2 Avatar asked Jul 07 '26 16:07

logical x 2


1 Answers

; The tilde prefix (~) prevents AHK from blocking key-down/up events.

~Capslock Up:: Send, {Capslock Up}


; The #If directive creates context-sensitive hotkeys and hotstrings:

#If (A_PriorHotkey = "~Capslock Up")

    :*:\alpha::α

#If

https://autohotkey.com/docs/commands/_If.htm

like image 196
user3419297 Avatar answered Jul 14 '26 10:07

user3419297