2

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?

logical x 2
  • 311
  • 4
  • 18

1 Answers1

3
; 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

user3419297
  • 9,537
  • 2
  • 15
  • 24
  • 1
    if you want to write the scripts with notepad, you can Change the script a little bit `:*:\alpha:: SendInput {U+0251} ;Send Unicode symbol alpha return` [UnicodeTable](https://unicode-table.com/en/search/?q=alpha) – stevecody Jan 04 '18 at 09:55
  • This worked. However, the Capslock is still in effect then! I solved this by adding "SetCapsLockState AlwaysOff" and this solved it for me. Thanks! : ) – logical x 2 Jan 04 '18 at 11:19