How to allow 2 scripts with 2 Sends at once Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Mister Fragalot

How to allow 2 scripts with 2 Sends at once  Topic is solved

08 Jun 2018, 11:38

Hi, I would like to run these 2 scripts simultaneously:

Code: Select all

~w:: 
	Send {Shift down}
	KeyWait, w
	Send {Shift up}
return

Code: Select all

~a::
sleep 100
MouseClick
return
I need the 2nd script to work, even while I'm holding down "w" in the first script.

Thank you.
Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to allow 2 scripts with 2 Sends at once

10 Jun 2018, 01:00

Hallo,
try:

Code: Select all

~*w:: 
	Send {Shift down}
	KeyWait, w
	Send {Shift up}
return
~*a::
sleep 100
MouseClick
return
This is one script with two hotkeys!
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: How to allow 2 scripts with 2 Sends at once

11 Jun 2018, 10:30

The functionality will be *slightly* different when you merge those scripts, due to the KeyWait.

The merged script *might* delay release of W by up to 100ms, if you tapped a while w was held. I am not really sure why he has a Sleep 100 at the start of a hotkey, if it is not needed then removing it would make the script more robust.

I presume that the KeyWait is dual-purpose, to suppress repeats and do an up event mapping?

The correct way of writing this script, to minimize the chance of the w:: hotkey and the a:: hotkey interfering with each other (And preserving all functionality of the original) is like this:

Code: Select all

w_held := 0

~*w:: 
	if (w_held)
		return ; Suppress repeats
	w_held := 1
	Send {Shift down}
	return

~*w up::
	w_held := 0
	Send {Shift up}
	return
	
~*a::
sleep 100
MouseClick
return
Also, note that as you are using a "Wild" hotkey (~*w::), you should probably be Sending using Blind Mode Send {Blind}{Shift down}
Last edited by evilC on 11 Jun 2018, 19:15, edited 3 times in total.
Mister Fragalot

Re: How to allow 2 scripts with 2 Sends at once

11 Jun 2018, 17:24

Thank you so much. It works well.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 77 guests