Accessing an In-game Menu

Ask gaming related questions (AHK v1.1 and older)
GiltEdge
Posts: 2
Joined: 28 Jun 2022, 13:56

Accessing an In-game Menu

Post by GiltEdge » 28 Jun 2022, 14:13

My first post, new to scripting.

I'm trying to access a specific menu item (in game) with a single key press, in this instance 'w'.
However, if I press down and release quickly, the command is ignored. If I hold it too long, I get repeated menu selections.
Is there a away to avoid this?

My basic code is this, but I've also tried various alternatives with no success.

Code: Select all

w::
	SendInput, t, t, t, t, t, 5   ;Wind check
	return
This is a menu item that is 5 levels down and then item 5 is the wind check.

Thanks for your help.

SandyClams
Posts: 63
Joined: 02 Jul 2020, 11:55

Re: Accessing an In-game Menu

Post by SandyClams » 28 Jun 2022, 15:19

if keypresses are ignored when they are sent too quickly, but produce the wrong result when they are held for too long, try this approach: rather than sending the entire sequence of keypresses with a single SendInput, send each keypress individually, first with a single SendInput for each key down, following each keydown with a Sleep specifying the length of time to hold down the key, and following each Sleep with another SendInput sending the key up of the same key. The appropriate length of time to hold each key will depend on the specifics of your game and will require some trial and error to determine, but taking this approach should eventually work once you specify a suitable length of time.

GiltEdge
Posts: 2
Joined: 28 Jun 2022, 13:56

Re: Accessing an In-game Menu

Post by GiltEdge » 29 Jun 2022, 10:39

This is the new code as recommended and it works perfectly. Thank you

Code: Select all

w::
	SendInput, {t Down}
	Sleep, 100
	SendInput, {t up}
	SendInput, {t Down}
	Sleep, 100
	SendInput, {t up}
	SendInput, {t Down}
	Sleep, 100
	SendInput, {t up}
	SendInput, {t Down}
	Sleep, 100
	SendInput, {t up}
	SendInput, {t Down}
	Sleep, 100
	SendInput, {t up}
	Sleep, 100
	Sendinput, 5 ;Wind Check
	return
[Mod edit: [code][/code] tags added.]
@SandyClams

Post Reply

Return to “Gaming Help (v1)”