AutoHotKey - Mantenha uma tecla pressionada

1

Eu tenho um script AutoHotKey que deve pressionar F3 quando eu pressionar Ctrl , e apertar F2 quando eu soltar o Ctrl .

Meu script atualmente:

$ctrl::
Suspend, On
Send, {F3}
While (GetKeyState("Ctrl",P))
{
}
Send, {F2}
Suspend, Off
Return

Mas quando pressiono Ctrl para baixo, não faz nada. Quando eu libero Ctrl , ele atinge tanto F3 e F2 . Alguém pode me dizer como consertar isso?

    
por Miniduus 03.07.2014 / 20:00

3 respostas

1

via: link

To hold down or release a key: Enclose in braces the name of the key followed by the word Down or Up. For example:

Send {b down}{b up}
Send {TAB down}{TAB up}
Send {Up down} ; Press down the up-arrow key.
Sleep 1000 ; Keep it down for one second.
Send> {Up up} ; Release the up-arrow key.

When a key is held down via the method above, it does not begin auto-repeating like it would if you were physically holding it down (this is because auto-repeat is a driver/hardware feature). However, a Loop can be used to simulate auto-repeat. The following example sends 20 tab keystrokes:

Loop 20 {
Send {Tab down} ; Auto-repeat consists of consecutive down-events (with no up-events).
Sleep 30 ; The number of milliseconds between keystrokes (or use SetKeyDelay).
}
Send {Tab up} ; Release the key.

The word DownTemp may also be used. Its effect is the same as Down except for the modifer keys (Control/Shift/Alt/Win). In those cases, DownTemp tells subsequent sends that the key is not permanently down, and may be released whenever a keystroke calls for it. For example, Send {Control DownTemp} followed later by Send a would produce a normal "a" keystroke, not a control-A keystroke.

    
por 03.07.2014 / 20:07
1

Este código fornece a funcionalidade desejada:

$~ctrl::
    send {f3}
    keyWait, ctrl
    send {f2}
return
    
por 23.09.2014 / 20:09
0

A opção keyup para as teclas de atalho parece ser o que você precisa.

Aqui está o código de trabalho testado:

Ctrl::
Send {F3}
keywait, Ctrl, L ; prevent F3 from firing while Ctrl is being held down.
return

Ctrl Up::Send {F2}
    
por 29.09.2016 / 05:59

Tags