Page 1 of 1

Spam a key whilst others are held down

Posted: 09 Nov 2018, 09:37
by LuckyLuciano
Hi,

I have a script as below:

Code: Select all

F1:: ; start
Loop
{
Send, {Left Down} 
Sleep 5000
Send, {Left Up}
Send, {Right Down}
Sleep 5000
Send, {Right Up}
}
Return

F2::ExitApp
I want it to also continuously press the space key (not just hold down like the left and right) while on this loop. How do I add this?

Thanks

Re: Spam a key whilst others are held down

Posted: 10 Nov 2018, 02:23
by Rohwedder
Hallo,
try:

Code: Select all

F1:: ; start
Send, {Space Down}
Loop
{
Send, {Left Down}
Sleep 5000
Send, {Left Up}
Send, {Right Down}
Sleep 5000
Send, {Right Up}
}
Return
F2::
Send, {Space Up}{Left Up}{Right Up}
ExitApp
Check this script by running this second script additionally.:

Code: Select all

#Persistent
SetTimer, KeyState, 200
KeyState: ;0/1 = Up/Down
Key1 = Space
Key2 = Left
Key3 = Right
Text =
MouseGetPos, MX, MY
While, Key%A_Index%
	Text .= Key%A_Index% ": " GetKeyState(Key%A_Index%) "`n"
ToolTip, % Text,MX+16,MY+32,4
Return

Re: Spam a key whilst others are held down

Posted: 11 Nov 2018, 03:18
by LuckyLuciano
Rohwedder wrote:
10 Nov 2018, 02:23
Hallo,
try:

Code: Select all

F1:: ; start
Send, {Space Down}
Loop
{
Send, {Left Down}
Sleep 5000
Send, {Left Up}
Send, {Right Down}
Sleep 5000
Send, {Right Up}
}
Return
F2::
Send, {Space Up}{Left Up}{Right Up}
ExitApp
Check this script by running this second script additionally.:

Code: Select all

#Persistent
SetTimer, KeyState, 200
KeyState: ;0/1 = Up/Down
Key1 = Space
Key2 = Left
Key3 = Right
Text =
MouseGetPos, MX, MY
While, Key%A_Index%
	Text .= Key%A_Index% ": " GetKeyState(Key%A_Index%) "`n"
ToolTip, % Text,MX+16,MY+32,4
Return
Thanks, but this doesn't work. It just presses space once at the start and not repeatedly. I'm currently running two scripts at the same time which achieves my goal. Just curious if it could be done in one script :)

Re: Spam a key whilst others are held down

Posted: 11 Nov 2018, 09:06
by Rohwedder
Hallo,
now I think I understand.
By continuous you mean repeatedly!
Try:

Code: Select all

F1:: ; start
SetTimer, RightLeft, 5000
SetTimer, Space, 100
Return
F2::
SetTimer, RightLeft, Off
SetTimer, Space, Off
Send, {Left Up}{Right Up}
ExitApp
RightLeft:
If RightLeft := !RightLeft
	Send, {Right Up}{Left Down}
Else
	Send, {Left Up}{Right Down}
Return
Space:
Send, {Space}
Return