Spam a key whilst others are held down

Ask gaming related questions (AHK v1.1 and older)
LuckyLuciano
Posts: 6
Joined: 14 Oct 2018, 08:57

Spam a key whilst others are held down

09 Nov 2018, 09:37

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
Rohwedder
Posts: 7655
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Spam a key whilst others are held down

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
LuckyLuciano
Posts: 6
Joined: 14 Oct 2018, 08:57

Re: Spam a key whilst others are held down

11 Nov 2018, 03:18

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 :)
Rohwedder
Posts: 7655
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Spam a key whilst others are held down

11 Nov 2018, 09:06

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

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: phalanxdarken, yuu453 and 110 guests