AutoHotKey哑语法问题(两个函数在同一个脚本中)

问题描述:

我有两个函数如下。他们自己工作,但我不能让他们在同一个脚本中工作。底部的那个不起作用。有人可以帮助我解决问题吗?例如,下面的“LShift & RShift”或“RShift & LShift”将不起作用。我不确定我做错了什么。AutoHotKey哑语法问题(两个函数在同一个脚本中)

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) 
    a:: MsgBox, Test 
    b:: MsgBox, Test 
    c:: MsgBox, Test 
    d:: 
    FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt 
    SendInput %CurrentDateTime% 
      Double_ALT :=false 
      return 
    s:: MsgBox, Test 
    f:: MsgBox, Test 
return 

LShift & RShift:: 
FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt 
SendInput %CurrentDateTime% 
return 

RShift & LShift:: 
FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt 
SendInput %CurrentDateTime% 
return 

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) 
    a:: MsgBox, Test 
    b:: MsgBox, Test 
    c:: MsgBox, Test 
    d:: 
    FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt 
    SendInput %CurrentDateTime% 
      Double_ALT :=false 
      return 
    s:: MsgBox, Test 
    f:: MsgBox, Test 
; return <-- likely your problem. 

; #IF <-- Use this if you don't want your hotkeys below effected by the IF Directive 

LShift & RShift:: 
FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt 
SendInput %CurrentDateTime% 
return 

RShift & LShift:: 
FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt 
SendInput %CurrentDateTime% 
return 
+0

谢谢。这解决了它。还有一个问题。 LShift&RShift似乎有一个小错误。有时候,我认为当你第三次快速按下Shift键时,它会以某种方式注册Shift,直到你再次按下其中一次Shift来释放它。当它处于该状态时,用鼠标选择的任何东西都会突出显示。这是不是最优雅的方式来做到这一点,或者你看到什么可能导致它和修复? –