"Exclusive" double tap SHIFT followed by a letter Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jeff_eisenberg
Posts: 5
Joined: 26 Apr 2017, 16:14

"Exclusive" double tap SHIFT followed by a letter

26 Apr 2017, 16:23

I'm trying to complete an autohotkey script where you can double tap any SHIFT key twice and follow it by a certain letter to activate a macro.
I have the following script but i have two "bugs" i can't figure out how to solve. I've tried other forums with no luck. Hoping someone can help me out.
I'm a little new at this.

Bug 1: The macro is activated if you press any letter in between the two SHIFTs where it should only be activated if you press the SHIFTs exclusively. For example, pressing SHIFT, s, SHIFT, d will enable the macro.

Bug 2: I'm not sure how this happens but with the following code, I periodically get all or some of the macros to activate while i'm typing. It seems to happen when I type the first capital letter in a sentence. But only sometimes. For example... "bla bla bla profiles. S"

I've fooled around with the timeouts but that doesn't seem to make much of a difference. Any help is appreciated.

Thanks,
Jeff.

Code: Select all

~Shift Up::
If (A_ThisHotkey == A_PriorHotkey && A_TimeSincePriorHotkey < 400)
{
    Double_SHIFT := true
    Sleep, 1500
    Double_SHIFT := false
}
return

; Press a key within two seconds after double tapping the Shift key, to activate an action:
#If (Double_SHIFT)
    d::
    FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt
    SendInput %CurrentDateTime%
            Double_SHIFT :=false
            return
    a:: MsgBox, Test
    s:: MsgBox, Test
    f:: MsgBox, Test
return
jeff_eisenberg
Posts: 5
Joined: 26 Apr 2017, 16:14

Re: "Exclusive" double tap SHIFT followed by a letter  Topic is solved

01 May 2017, 12:18

endKeys := "{BS}{Enter}{Insert}{Home}{Pgup}{PdDwn}End}{Delete}"
. "{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}"
. "{LShift}{RShift}{Tab}{Esc}{CAPSLOCK}{Ctrl}{PrintScreen}{NumLock}"
. "{Numpad0}{Numpad0}{Numpad0}{Numpad0}{Numpad0}{Numpad0}{Numpad0}"
. "{Numpad7}{Numpad8}{Numpad9}{NumpadDel}{Up}{Down}{Left}{Right}"

~Shift Up::
Input, key, V L1 t0.5 E, % endKeys
If (Errorlevel ~= "Shift") {
Double_SHIFT := true
Sleep 2000
Double_SHIFT := false
}
return

; Press a key within two seconds after double tapping the Shift key, to activate an action:
#If (Double_SHIFT)
d::
FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt
SendInput %CurrentDateTime%
Double_SHIFT :=false
return
a:: MsgBox, Test
s:: MsgBox, Test
f:: MsgBox, Test
return
MrMacroMan17070
Posts: 2
Joined: 06 Mar 2018, 15:33

Re: "Exclusive" double tap SHIFT followed by a letter

17 Apr 2018, 13:26

Is the second posting a working script? I like this idea!
MrMacroMan17070
Posts: 2
Joined: 06 Mar 2018, 15:33

Re: "Exclusive" double tap SHIFT followed by a letter

17 Apr 2018, 13:26

Is the second posting a working script? I like this idea!
jeff_eisenberg
Posts: 5
Joined: 26 Apr 2017, 16:14

Re: "Exclusive" double tap SHIFT followed by a letter

19 Apr 2018, 10:14

I think this was the best I got it to work. I haven't had any complaints from users yet.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: "Exclusive" double tap SHIFT followed by a letter

19 Apr 2018, 13:36

This scenario is non-trivial in AHK generally, due to the inherent "look into the future" nature of the problem, and especially if you want to be able to do it with multiple keys at once (Because of the way AHK threading works)
However, in your use-case, you have circumvented a lot of the complexity by using a non-printable key, and only reacting on release of that key.
I suspect this was more out of necessity than choice.

Therefore, you may be interested in my TapHoldManager library. It only currently supports multiple taps and holds of a single key (No multi-key combos), but there is a bunch of code in there you may well find useful - Note no use of "blocking waits" (KeyWait or GetKeyState loops); this is how to solve the "look into the future" issue that likely confounded you, without causing all kinds of nasty side-effects.

I would potentially be interested in expanding THM to support multi-key combos, but I have not really put my mind as to how I would achieve it.
If you have any thoughts, then I am all ears.
dinkleman
Posts: 3
Joined: 26 Nov 2022, 18:34

Re: "Exclusive" double tap SHIFT followed by a letter

30 Nov 2022, 17:00

:trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface:
:dance: If someone made this it would be the most powerful script known to man, imagine all the macros :dance:
:trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, mikeyww and 318 guests