2017-06-21 1 views
0

J'ai deux fonctions ci-dessous. Ils travaillent par eux-mêmes, mais je ne peux pas les amener à travailler dans le même script. Celui en bas ne fonctionnera pas. Quelqu'un peut-il m'aider à réparer. Par exemple, sous "LShift & RShift" ou "RShift & LShift" ne fonctionnera pas. Je ne suis pas sûr de ce que je fais mal.Problème de syntaxe automatique d'AutoHotKey (Deux fonctions dans le même script)

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 

Répondre

0
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

Merci. Cela l'a réparé. Une autre question. Le LShift & RShift semble avoir un bug mineur. Parfois, je pense que lorsque vous appuyez rapidement sur une touche Shift une troisième fois, le Shift est en quelque sorte enregistré comme étant maintenu enfoncé jusqu'à ce que vous appuyiez de nouveau sur l'un des Shifts un certain nombre de fois pour le relâcher. Quand c'est dans cet état, tout ce que vous sélectionnez avec la souris est surligné. N'est-ce pas la façon la plus élégante de le faire ou voyez-vous ce qui pourrait en être la cause et une solution? –