SEND command act like sticking to the previous line of keys?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pk23
Posts: 110
Joined: 24 Apr 2015, 00:49

SEND command act like sticking to the previous line of keys?

17 Oct 2018, 20:08

The script is as simple as follows, and the target program is warcraft.exe which is an RTS game:

Code: Select all

#SingleInstance FORCE 
SetTitleMatchMode Regex 
#Persistent          
SendMode Input
DetectHiddenWindows, On

#IfWinActive ahk_class ((Warcraft III)|(OsWindow)|(Qt5QWindowIcon))
Tab & LButton::
	KeyWait, Tab
	KeyWait, LButton
	BlockInput, On
	
	SendInput, +{LButton}
	Sleep, 200
	SendInput, ^1                ;line Z
	Sleep, 200                   ;line X
	SendInput, {LButton}         ;line Y
	BlockInput, Off
	return
In the actual test, if I increase the sleep time of line X by a little, for example, 500ms, the behavior of line Y will be normal ( send the left mouse click only )
However, if the line X is set to 200ms or less, the behavior of the line Y will be very strange, acting like sending the CTRL+LBUTTON as if the CTRL of the line Z has not been released.

I've never met this issue before, maybe this is a defect of warcraft.exe? I don't know and not sure. However, the problem is still the problem which needs to be solved, and manually simulating keys input as fast as I can did not have this problem, and only script simulation will encounter this issue.

I tried to add between line X and Y:

Code: Select all

SendInput, {Ctrl Up}
or

Code: Select all

KeyWait, Ctrl, T3
Both are not working, still behave like CTRL-LBUTTON. How can I fix this problem? Ty
eqv
Posts: 72
Joined: 18 Sep 2018, 22:17

Re: SEND command act like sticking to the previous line of keys?

17 Oct 2018, 20:26

pk23 wrote:
17 Oct 2018, 20:08
In the actual test, if I increase the sleep time of line X by a little, for example, 500ms, the behavior of line Y will be normal ( send the left mouse click only )
However, if the line X is set to 200ms or less, the behavior of the line Y will be very strange, acting like sending the CTRL+LBUTTON as if the CTRL of the line Z has not been released.
pk23 wrote:
17 Oct 2018, 20:08
I tried to add between line X and Y:

Code: Select all

SendInput, {Ctrl Up}
or

Code: Select all

KeyWait, Ctrl, T3
Both are not working, still behave like CTRL-LBUTTON. How can I fix this problem? Ty
If the problem occurs even when you do nothing; then is probably a function of the game. It's assuming that people can't press that fast.

Check this post for more solutions:
https://autohotkey.com/board/topic/1117 ... he-basics/

There is a chance that your physical input enter in conflict with AHK. Try this:

Code: Select all

#SingleInstance FORCE 
SetTitleMatchMode Regex 
#Persistent          
SendMode Input
DetectHiddenWindows, On

#IfWinActive ahk_class ((Warcraft III)|(OsWindow)|(Qt5QWindowIcon))
Tab & LButton::
	KeyWait, Tab
	KeyWait, LButton
	BlockInput, On
	
	keys()
	SendInput, +{LButton}
	Sleep, 200
	keys()
	SendInput, ^1                ;line Z
	Sleep, 200                   ;line X
	keys()
	SendInput, {LButton}         ;line Y
	BlockInput, Off
	return
	
	keys() {
	While (getKeyState("Ctrl","P") || getKeyState("Win","P") || getKeyState("Shift","P") || getKeyState("Alt","P"))
		Sleep 5
	}
This will prevent your press Ctrl\Win\Shift\Alt, while the script it's sending commands.

Hope it helps,
pk23
Posts: 110
Joined: 24 Apr 2015, 00:49

Re: SEND command act like sticking to the previous line of keys?

17 Oct 2018, 20:47

@eqv Thank you for your detailed and enthusiastic help. I just tried to add the keys() function and test again, the problem still exists.

As for the game does not allow players to input so fast, tbh 200ms is actually not that fast, b/c the APM of top RTS players can reach 400, that is, their input interval is about 60 * 1000 / 400 ≈ 150ms. It's very surprising and unlikely if an RTS game does not allow input just per 200ms.

--
Edit: Also tried replace line Z with

Code: Select all

	SendInput, {Ctrl Down}
	SendInput, 1                ;line Z
	SendInput, {Ctrl Up}
still not working... :think:

--
Edit2: Ah, I see, it's not CTRL at work, but double-click at work. Line Y and this line are identified as double-click LButton, same result as CTRL-LButton:

Code: Select all

SendInput, +{LButton}
problem solved, ty guys.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, Frogrammer and 260 guests