Press key from time to time

Ask gaming related questions (AHK v1.1 and older)
gsimoesgss2001
Posts: 1
Joined: 17 Dec 2017, 21:36

Press key from time to time

17 Dec 2017, 21:42

Hello, I am new to AHK, I was trying to make a script but it did not work very well, haha ...
I decided to ask for help here, forgive me if I'm not in the right place, I've never used this forum before, but let's get down to business:
I want to create a script that when I press the P key it sends the command to the computer to press the Up key every 1 second at the time I am pressed, and when I release the P key it stops pressing, for example.
I press P now and it will send the Up command every 1 second as long as I have the P key pressed, when I release the key it cancels, more if i press key P for 10 seconds, press keys up 1 in 1 second, up, 1 second, up, 1 second, up, 1 second, up, 1 second ...
Can anyone help me do this?
Thank you...
User avatar
Dumitas
Posts: 167
Joined: 14 Dec 2017, 21:32

Re: Press key from time to time

17 Dec 2017, 22:14

Hope this help.

Code: Select all

p::
Loop
	{
		If GetKeyState("p")
		Send 1
		Else
		Break ; Work until you release the key.
		sleep 1000 ; 1 sec wait btw keys
	}
return

Check:Loop and GetKeyState
Image

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 75 guests