If a key is pressed then

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
AnaSystem
Posts: 4
Joined: 27 Jun 2021, 10:23

If a key is pressed then

Post by AnaSystem » 30 Jun 2021, 09:11

Hello, I would like to make a script that does pretty much that, that presses f all the time so a loop but if a key is press eg "u" then it exits the loop. I think it would need something like GetKeyState but I didn't quite get it.

Code: Select all

a::
Loop {
	 ; if "x" is to press press without stopping and without delay on f as long as the "u" key is not pressed}[/code

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: If a key is pressed then

Post by swagfag » 30 Jun 2021, 17:11

its not clear what u want. this will start spamming f indefinitely when u press a. pressing u will stop spamming f

Code: Select all

#Requires AutoHotkey v2.0-a138-7538f26f

sendsF() => Send('f')

a::SetTimer(sendsF, 1)
u::SetTimer(sendsF, 0)

AnaSystem
Posts: 4
Joined: 27 Jun 2021, 10:23

Re: If a key is pressed then

Post by AnaSystem » 01 Jul 2021, 06:46

@swagfag
Attachments
Screenshot 2021-07-01 134519.png
Screenshot 2021-07-01 134519.png (4.13 KiB) Viewed 901 times

gregster
Posts: 9023
Joined: 30 Sep 2013, 06:48

Re: If a key is pressed then

Post by gregster » 01 Jul 2021, 06:49

You posted in AutoHotkey v2 Help - that's the subforum where you can rightfully expect AHK v2 code ;)
The regular v1 'Ask For Help' is here: https://www.autohotkey.com/boards/viewforum.php?f=76 (one level up)

Post Reply

Return to “Ask for Help (v2)”