Come posso imitare & # 8220; Visual Studio Ctrl-K, C & # 8221; comportamento della macro in due passaggi usando Autoit / Autohotkey?

StackOverflow https://stackoverflow.com/questions/200587

  •  03-07-2019
  •  | 
  •  

Domanda

Sto cercando di impostare le macro AutoHotkey per alcune attività comuni e voglio che i tasti di scelta rapida imitare il collegamento in due passaggi di Visual Studio " comportamento - ovvero premendo Ctrl - K si abilita la modalità macro " ;; all'interno della modalità macro, premendo determinati tasti verrà eseguita una macro e quindi verrà disabilitata la "modalità macro" e qualsiasi altro tasto disabiliterà semplicemente la modalità macro.

Esempio: quando si digita un nome file, voglio essere in grado di inserire la data odierna toccando Ctrl - K , quindi premendo D .

Qualcuno ha un buon esempio di uno script AutoHotkey con stato che si comporta in questo modo?

È stato utile?

Soluzione

Questo script Autohotkey, quando premi ctrl + k , ti aspetta per premere un tasto e se premi d , inserirà la data corrente.

^k::
Input Key, L1
FormatTime, Time, , yyyy-MM-dd
if Key = d
    Send %Time%
return

Altri suggerimenti

Una leggera variazione sulla risposta accettata - questo è quello che ho finito per usare. Sto catturando Ctrl + LWin (tasto Windows sinistro) in modo che non sia in conflitto con le scorciatoie Ctrl-K integrate VS.

; 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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top