gaming code help

Ask gaming related questions
badchicken
Posts: 19
Joined: 10 Feb 2016, 14:24

gaming code help

15 Apr 2016, 16:07

hello i have the following code posted under

Code: Select all

$q::
freq:=20
loop
{
   if not GetKeyState("q", "P")
     break
     send {q down}{q up}
     sleep %freq%
     send {e down}{e up}
     sleep %freq%
}
i need to send the w key but after 2 seconds while im holding down the q key

so to clarify, it starts sending q and e after i hold down q, but after 2 seconds have passed, w will start being sent alongside with q and e, while im holding down the q

thank in advance for ur time :)
Leli196
Posts: 206
Joined: 29 Aug 2015, 05:47
Location: Germany

Re: gaming code help

15 Apr 2016, 16:16

badchicken wrote: i need to send the w key but after 2 seconds while im holding down the q key
Please clarify what you want to achieve. Do you want q keep sending q and e while it is pressed until 2 seconds elapsed and then: send w repeatedly or once or alltogether?

Btw I cannot figure out how your code is even capable of sending w. I do not see any Send commands that send w.


Greetings Leli196
badchicken
Posts: 19
Joined: 10 Feb 2016, 14:24

Re: gaming code help

15 Apr 2016, 17:11

yes exactly like what u have mentioned, and after 2 seconds have elapsed, w to be sent repeatedly with the q and e

so to clarify more, while holding down the q button, it starts sending q e q e q e q e , after 2 seconds have passed it will start sending q w e q w e q w e q w e, while im holding down the q
Leli196
Posts: 206
Joined: 29 Aug 2015, 05:47
Location: Germany

Re: gaming code help

15 Apr 2016, 21:40

Alright. So your code is a good start. You just have to add a few lines for time:

Code: Select all

$q::
freq:=20
loop_start:=A_TickCount	; A_TickCount is a built in var that contains the time since system boot
loop
{
   if not GetKeyState("q", "P")
     break
     send {q down}{q up}
     sleep %freq%
     if (A_TickCount - loop_start >= 2000) {
     	send {w down}{w up}
     	sleep %freq%
     }
     send {e down}{e up}
     sleep %freq%
}
However, I would suggest a few other changes, e.g. you generally do not need to have down and up for a keypress and instead of sleep you could use SetKeyDelay to specify your desired delay (https://autohotkey.com/docs/commands/SetKeyDelay.htm):

Code: Select all

$q::
SetKeyDelay, 20, 20
loop_start := A_TickCount

while GetKeyState("q", "P") {
	Send, q
	if (A_TickCount - loop_start >= 2000) {
		Send, w
	}
	Send, e
}
Return
If anything is unclear just read the documentation or ask again. I hope it helps.
badchicken
Posts: 19
Joined: 10 Feb 2016, 14:24

Re: gaming code help

16 Apr 2016, 05:51

ty very much its working!!! :) ! this is awesome
badchicken
Posts: 19
Joined: 10 Feb 2016, 14:24

Re: gaming code help

16 Apr 2016, 06:05

hey im sorry but i just realized, after a long duration of holding down the q when i release its prompting the following error dialog box


71 hotkeys have been received in the last 0ms.

do you want to continue?
(see#MaxHotKeysPerinterval in the help file)

what should i do
badchicken
Posts: 19
Joined: 10 Feb 2016, 14:24

Re: gaming code help

16 Apr 2016, 06:11

ok i added this #MaxHotKeysPerInterval 200 at the top of the script and it worked and again thx for the code which u have provided it helps alot
User avatar
HinkerLoden
Posts: 93
Joined: 23 Mar 2016, 07:50
GitHub: HinkerLoden

Re: gaming code help

16 Apr 2016, 06:14

by pressing the Hotkey you activate many instances. maybe $q UP:: | $q Down:: fix it or rise up the Hotkeysperinterval

Return to “Gaming”

Who is online

Users browsing this forum: Google [Bot] and 30 guests