How can I mimic Visual Studio's “Ctrl-K, C” two-step macro behaviour using Autoit / Autohotkey?

后端 未结 2 396
南方客
南方客 2021-02-05 13:11

I\'m trying to set up AutoHotkey macros for some common tasks, and I want the hotkeys to mimic Visual Studio\'s \"two-step shortcut\" behaviour - i.e. pressing Ctrl-<

2条回答
  •  逝去的感伤
    2021-02-05 13:49

    A slight variation on the accepted answer - this is what I've ended up using. I'm capturing Ctrl+LWin (left Windows key) so it doesn't conflict with VS inbuilt Ctrl-K shortcuts.

    ; Capture Ctrl+Left Windows Key
    ^LWin::
    
    ; Show traytip including shortcut keys
    TrayTip, Ctrl-Win pressed - waiting for second key..., t: current time`nd: current date, 1, 1
    
    ; Capture next string input (i.e. next key)
    Input, Key, L1
    
    ; Call TrayTip with no arguments to remove currently-visible traytip
    TrayTip
    
    if Key = d
    {
        FormatTime, Date, , yyyyMMdd
        SendInput %Date%
    } 
    else if Key = t 
    {
        FormatTime, Time, , hhmmss
        SendInput %Time%
    }   
    return
    

提交回复
热议问题