How to make hotkeys case 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 hotkeys case sensitive

29 Apr 2017, 15:48

Is it possible to make hotkeys case sensitive.

Example: I want a "^x::" script to perform differently than a "^X::" --- where the latter will work if I press "CTRL-X" while the capslock key is activated.

To be clear -- I am already aware of the "^+x" option -- BUT this is a "CTRL-SHFT-x" function which requires that both the Shift and Control keys be held down when striking the x key.

I want the Autohotkey script to be able to distinguish the difference between "^x::" and "^X::" simply because the latter is executed while the CapsLock key is "ON." That way I can double the number of alphabet combinations (^x::) combinations -- WITHOUT using up more key combinations and without having to hold 3 keys down at one time.

This would double the alphabet capacity of "^x::" and "#x::" and "!x::" -- giving me an additional 78 scripting possibilities -- while only holding-down two keys (with and without an activated CapsLock).

This may not be possible, but I WAS surprised AutoHotKey did not automatically differentiate between "^x::" and "^X::" -- given that these actually are two very different entries.

Thanx for any help you can provide.
Last edited by Justice Central on 29 Apr 2017, 20:32, edited 1 time in total.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to make hotkeys cases sensitive

29 Apr 2017, 16:23

Thanks, this is an interesting idea. Here are two approaches. The key idea is this:
#If GetKeyState("CapsLock", "T")

Code: Select all

;approach 1
x::
^x::
+x::
^+x::
MsgBox, % GetKeyState("CapsLock", "T") " " A_ThisHotkey
return

;==================================================

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

x::
^x::
+x::
^+x::
MsgBox, % "0 " A_ThisHotkey
return
[EDIT:] I agree that the behaviour is a little surprising. Thinking through, how would you handle 9 (capslock is on) v. 9 (capslock is off), so perhaps the current behaviour is for the best.

I was myself a little unsure on this issue, regarding capslock and/or shift. For example, on my PC, Shift+3 gives £, but '£::' does nothing, although I don't personally mind this.

Having said all of that, there is special handling for the Numpad keys, for Numlock on/off:
- NumpadHome (Numlock off)
- Numpad1 (Numlock on)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
eduardoblu
Posts: 19
Joined: 28 Apr 2017, 18:54

Re: How to make hotkeys cases sensitive

29 Apr 2017, 17:00

You can also use Capslock to trigger your script on and off, and use two diferent scripts for diferent purposes, assigning manualy hotkeys to each needed, either when on or off.

Be careful with that, if you choose that way, because you may need to force capslook as a hotkey to activate itself or he may conflict.
Justice Central
Posts: 4
Joined: 29 Apr 2017, 14:49

Re: How to make hotkeys case sensitive

29 Apr 2017, 20:59

As a follow-up to my Posted question -- I have seen a script command that reads: "StringCaseSense, On" -- which I thought would solve my problem.

But I have never been able to get it to do what it sounds like it should do -- namely -- make the script it resides in 'Case Sensitive.'

Does anyone know how this command is supposed to be used or what it actually does? I would need a pinpoint specific syntax script example of how it should be written for a "^x::" script command -- as I am not a wiz-kid with this scripting language.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], Rohwedder and 48 guests