How to Make AHK scripts Caps Sensitive

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Justice Central
Posts: 4
Joined: 29 Apr 2017, 14:49

How to Make AHK scripts Caps Sensitive

30 Apr 2017, 21:36

By default, AHK is Caps Insensitive -- for backwards compatibility reasons I have read.

Is there any work-around I can do to make AHK scripts Caps Sensitive?

I want AHK to differentiate between ^a:: and ^A::

By default AHK sees these as being identically the same. But I want ^a:: to execute a different function than the ^A:: command. So if I have CapsLock on when I press CTRL-A it will execute the ^A:: command, and if I have CapsLock off when I press CTRL-a it will execute the ^a:: command -- a totally different operation.

This seems to require that AHK be Caps Sensitive. But it also seems to require that AHK be aware of the state or status of the CapsLock -- whether it is "on" (activated) or off. I note that AHK can detect the state of a key -- as to whether it is being pressed or released -- BUT it is not clear if it can detect whether the CapsLock is "On" (activated) or off.

I am already aware of the ^+a:: option -- BUT this is a CTRL-SHFT-a 3-key hold-down operation. CapsLock sensitivity would keep it a 2-key operation because you don't have to be pressing that key -- it stays on.

Any help would be borderline miraculous. Have spent 100 hours going nowhere with this. Thanx.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: How to Make AHK scripts Caps Sensitive

01 May 2017, 02:07

I guess you didn't spend two minutes of your 100 hours, reading this GetKeyState :wave:
You might also be interested in #if.
Good luck.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to Make AHK scripts Caps Sensitive

01 May 2017, 02:30

I would have hoped I'd made things reasonably clear here:
How to make hotkeys case sensitive - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=31167

To be extra clear:

Code: Select all

#If GetKeyState("CapsLock", "T")
^x::
MsgBox, % "1 " A_ThisHotkey
return
#If

^x::
MsgBox, % "0 " A_ThisHotkey
return
If that doesn't work for you, then perhaps we can suggest other ideas.

Note: I'll be AFK for a while, so may not respond for some time.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Justice Central
Posts: 4
Joined: 29 Apr 2017, 14:49

Re: How to Make AHK scripts Caps Sensitive

02 May 2017, 00:59

I had been hoping to simply make the AHK program, itself, Caps-sensitive. Judging from the answers it sounds like this cannot be done.

The problem with most scripts is that my version of AHK cannot load if it sees this #If statement in the script. As I understand it, only the AHK_L version can use this statement.

I had already found the script Helget posted and someone else linked to. They do work, but all the getkeystate scripts I've seen previously had a lot of parenthesis in them and none of them worked. The only script that worked was the script that has no parentheses in it. These getkeystate scripts are not as simple as just having AHK recognize that ^a:: is different than #A:: I was hoping for a simpler solution.

Bottom line is I got the answer I needed to have. No point wasting any more time trying to achieve the impossible.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to Make AHK scripts Caps Sensitive

02 May 2017, 01:11

OK, I didn't know you were using AutoHotkey Basic. This might work for you:

Code: Select all

^x::
GoSub, % GetKeyState("CapsLock", "T") ? "CapsCtrlX" : "CtrlX"
return

CapsCtrlX:
MsgBox, % A_ThisLabel
return

CtrlX:
MsgBox, % A_ThisLabel
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Dobbythenerd1 and 322 guests