1
votes

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.

~Shift Up::
If (A_ThisHotkey == A_PriorHotkey && A_TimeSincePriorHotkey < 400)
{
    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
1
I can't recreate the 2nd issue.errorseven
Thanks so much. i'm going to test this for a while. The fix may take care of the 2nd issue. Will let you know.Jeff E

1 Answers

2
votes

Fix for Bug 1:

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}"
     . "{LAlt}{RAlt}{.}{,}{/}"

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

; Press a key within two seconds after double tapping the Alt key, to activate an action:
#If (Double_ALT)
    d::
    FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt
    SendInput %CurrentDateTime%
            Double_ALT :=false
            return
    a:: MsgBox, Test
    s:: MsgBox, Test
    f:: MsgBox, Test
return