Create a hotkey for a series of inputs Topic is solved

Ask gaming related questions
delseyyy
Posts: 5
Joined: 01 Jan 2018, 17:00

Create a hotkey for a series of inputs

01 Jan 2018, 17:17

I want to be able to run a script when typing a certain sequence of characters.
For example:

Hold Alt (!), then type A, type B, Type C. (Not all together, one after the other)
My idea was to create a hotkey for !A:: then check if B and C are typed in a certain timespan. If a key other then b is being pressed, exit the script.

Now my question is: How do I check if a Key is being pressed in X ms? Is there a better way to do this whole thing that I just dont know of? Thanks in advance.
Rohwedder
Posts: 2281
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Create a hotkey for a series of inputs  Topic is solved

02 Jan 2018, 06:16

Hallo,
try:

Code: Select all

!a::
	EndTime := A_TickCount + 3000 ;max. timespan 3 seconds
	Keys = a
	Loop
	{
		Input, Key, ML1T.2
		Keys .= Key
	}
	Until (A_TickCount > EndTime) Or !InStr("ab",Keys)
	If Keys = abc
		MsgBox, True
	Else
		MsgBox, False
Return

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 45 guests