Woooooow! Thanks in million times Exaskryz!
How could I be so stupid!!!
Really Really appreciate your help!
Hold/Toggle key script
Re: Hold/Toggle key script
Hey can anyone make a script that holds 2 keys? I need a script that holds W for 7 Sec, then holds S for 7 sec also and the toggle is F1? Please help thanks
-
- Posts: 1
- Joined: 06 Feb 2016, 15:54
Re: Hold/Toggle key script
This script allows a single key to be used as either a regular key or to toggle itself on/off by holding down for about 1 second then clicking the button again to cancel the loop. It's not perfect but it works.
Code: Select all
$1::
keyDwn = 1
keyLoop = OFF
Loop
{
sendInput 1
sleep 250
cFct_GetKeyState(keyDwn, keyEsc, keyLoop)
} Until (keyLoop = "OFF")
sendInput {F2 Up}
sendInput {ENTER}
return
$1 up::
If (keyEsc = "ON") && (keyLoop = "ON")
{
keyLoop = OFF
}
return
cFct_GetKeyState(keyDwn, ByRef keyESC, ByRef keyLoop)
{
GetKeyState, keyState, %keyDwn%, P
if keyState = D
{
sleep 250 ;second timer helps avoid accidently trigging the loop if spamming the key
GetKeyState, keyState, %keyDwn%, P
if keyState = D
{
keyESC = OFF
keyLoop = ON
}
} else {
keyEsc = ON
}
}
Re: Hold/Toggle key script
Hello, I have a question.
f1 is used for toggling a command.
Pressing f1 will start the loop, pressing it again stop.
Below is a code which used settimer
It seems pressing f3 again doesn't break the ongoing loop.
It increases the 'presscount' variable, but loop doesn't break.
My guess is 'testa' subrountine isn't allowed to have more than one instance, maybe because
maxthreadsperhotkey doesn't applied to subrountines?
Is that correct?
If so how can i work around this?
Code: Select all
#Maxthreadsperhotkey 2
f1::
{
Togloop := !Togloop
while Togloop {
send %Togloop%
sleep 5000/(3-presscount)
send again
sleep 5000
Tooltip, %A_Index%
}
Tooltip
Return
}
f1 is used for toggling a command.
Pressing f1 will start the loop, pressing it again stop.
Below is a code which used settimer
Code: Select all
#Maxthreadsperhotkey 2
f3::
{
presscount++
Settimer, testa, -800
Return
}
testa:
{
Togloop := !Togloop
Tooltip, % (presscount = 1 ? "short" : "long")
while Togloop {
send %Togloop%
sleep 5000/(3-presscount)
send again
sleep 5000
}
Tooltip
presscount:=0
Return
}
It increases the 'presscount' variable, but loop doesn't break.
My guess is 'testa' subrountine isn't allowed to have more than one instance, maybe because
maxthreadsperhotkey doesn't applied to subrountines?
Is that correct?
If so how can i work around this?
Re: Hold/Toggle key script
If you (like me) were struggling to find the "v2" version of this, there's a thread over here: viewtopic.php?f=82&t=122046
Who is online
Users browsing this forum: aitaixy, Anput, dangoscrub, Google [Bot], joedf, Nerafius and 144 guests