2017-04-17 146 views
1

我希望能够双击SHIFT键后跟一个字母来激活一个动作。谁能帮忙?能够双击SHIFT键会很好。双击SHIFT键后跟一个字母

就像?

< + < +或> +> +那么D 做某事 返回

~Shift Up:: 
If (A_ThisHotkey == A_PriorHotkey && A_TimeSincePriorHotkey < 500) 
{ 
    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) 
    a:: MsgBox, This macro has not yet been enabled. Contact IT for suggestions. 
    b:: FormatTime, CurrentDateTime,,MM/dd/yy - hh:mmtt 
    SendInput %CurrentDateTime% 
    c:: MsgBox, This macro has not yet been enabled. Contact IT for suggestions. 
return 
+0

要使用热键执行多个命令,请将**第一行放在热键**定义下,并使最后一行成为**返回**。请参阅[简介和简单示例](https://www.autohotkey.com/docs/Hotkeys.htm#Intro)和[为什么我的脚本中的某些行不会执行?](https://autohotkey.com/docs/ FAQ.htm#自动执行)。 – user3419297

回答

2
~Shift Up:: 
If (A_ThisHotkey == A_PriorHotkey && A_TimeSincePriorHotkey < 500) 
{ 
    Double_SHIFT := true 
    ToolTip, Double_SHIFT  ; remove this line, if you don't want a tooltip displayed 
    Sleep, 2000 
    Double_SHIFT := false 
    ToolTip     ; remove this line, if you don't want a tooltip displayed 
} 
return 

; Press a key within two seconds after double tapping the Shift key, to activate an action: 

#If (Double_SHIFT) 

    a:: MsgBox, Double_SHIFT + a 

    b:: MsgBox, Double_SHIFT + b 

#If 
+0

不错的使用内置变量和工具提示! –

+0

这很好。如果您连续输入两次大写字母,我遇到了另一个触发问题。这不是。谢谢。两个问题; 1 ..你会如何补充这一点,以便左侧双转换或右侧双转换将触发它。 2.当您双击shift键或在连续两次输入任何大写字母时,工具提示会弹出。有没有办法不让这个消息弹出? –

+0

请参阅我编辑的答案。 – user3419297

0

显示消息框时d按压

~LShift::ShiftPressed() 
~RShift::ShiftPressed() 
$d::DPressed() 

ShiftPressed() 
{ 
    global t1,t2 
    t1 := t2 
    t2 := A_TickCount 
} 

DPressed() 
{ 
    global t1,t2 
    if (A_TickCount < t1 + 1000) && (A_TickCount < t2 + 1000) 
    MsgBox Shift Shift D Pressed 
    else 
    sendinput d 
} 
+0

这太棒了!谢谢。如果我想在按下Shift/Shift之后向其中添加其他操作,然后说出不同的字母(如“f”),是否有一种优化的方式可以对此进行缩放? –

+0

我想这将取决于其他行动的细节。您可以将参数传递给函数。如果shift,shift,d表示做了10次转换,shift,f表示做100次,我会定义两个热键:'$ d :: DoSomething(10,“d”)'和'$ f :: DoSomething (100, “F”)'。然后定义像'DoSomething(count,mykey)'这样的函数 –

相关问题