How to get the actual hotstring typed with capitalization in AutoHotKey?

Viewed 140

I am using hotstrings in AutoHotKey and the output is reliant on if characters are capitalized. Is there a way to determine if characters in the keys typed that triggered the hotkey are capitalized? I tried using A_ThisHotkey, but it does not seem to be case sensitive. Please let me know if you have a solution. Thanks.

2 Answers

I'm not aware of a built in way to do this, but maybe you'd be fine with just creating more hotstrings and using the C option for case sensitivity like this:

:C:hello::
:C:Hello::
:C:HeLLo::
:C:HELLO::
    MsgBox, % A_ThisHotkey
return

Example request from comments:

hotstrings := "hello,HELLO,HeLlo,HellO,hElLo,hellO"
for each, hotstring in StrSplit(hotstrings, ",")
    Hotstring(":CB0*?:" hotstring, Func("MyFunction"))
return

MyFunction()
{
    MsgBox, % "Hotstring triggered!`n" A_ThisHotkey
}

You can activate the case sensitivity option before defining your Hotstrings

#Hotstring c
::Hello::Hi ; will be triggered only if you exactly typed these letters case-sensitive
Related