Help with making code for keyboard Macro

Ask gaming related questions
omeganexus
Posts: 2
Joined: 24 Apr 2024, 16:02

Help with making code for keyboard Macro

24 Apr 2024, 16:08

I need help creating a macro that works in the Armored Core 6 game.
Basically, I need that when pressing the Shift+Q Keys, the Macro leaves the Q and E Keys pressed infinitely, until the Q Key is pressed, thus releasing both keys.
Last edited by gregster on 24 Apr 2024, 18:29, edited 1 time in total.
Reason: Disapproved four duplicate topics. Please only post once and be patient. As a new user, your posts need to be approved. Thank you!
Noitalommi_2
Posts: 260
Joined: 16 Aug 2023, 10:58

Re: Help with making code for keyboard Macro

24 Apr 2024, 21:18

Hi. @omeganexus

Can't test it, but this might work.

Code: Select all

#Requires AutoHotkey 2.0
#SingleInstance


+q::SendEvent "{q down}{e down}" ; shift+q
q::{

	if GetKeyState("q")
		SendEvent "{q up}"
	if GetKeyState("e")
		SendEvent "{e up}"
}
omeganexus
Posts: 2
Joined: 24 Apr 2024, 16:02

Re: Help with making code for keyboard Macro

26 Apr 2024, 19:07

Noitalommi_2 wrote:
24 Apr 2024, 21:18
Hi. @omeganexus

Can't test it, but this might work.

Code: Select all

#Requires AutoHotkey 2.0
#SingleInstance


+q::SendEvent "{q down}{e down}" ; shift+q
q::{

	if GetKeyState("q")
		SendEvent "{q up}"
	if GetKeyState("e")
		SendEvent "{e up}"
}
The code you posted didn't work. I needed the Q and E Keys to be pressed infinitely, in a loop, until the Q Key was pressed. However, I realized that I couldn't use the Q and E Keys as a condition for ending the loop, after all they were always in the "Down" state.

That's why I used a new shortcut, the Shift+R hotkey to activate the Macro, and the R Key as a condition for the end of the loop. However, I realized that the GetkeyState function takes a few milliseconds to update, and that's why I needed to add a sleep with 150 milliseconds to give the R key's state time to update.

In the game it worked really well. Still, thank you very much for your help.

Code: Select all

+r::{
	sleep 150
	loop{
	SendEvent "{q down}{e down}" ; shift+r
} until KeyWait("r" , "D")
	SendEvent "{q up}{e up}"
}

Return to “Gaming”

Who is online

Users browsing this forum: changlish76 and 13 guests