Repeating macro

How can be this controlled in that simulator? Can HIDmacros be used with this application?
Post Reply
Atlime
Posts: 1
Joined: 18 Jun 2017, 19:32

Repeating macro

Post by Atlime » 18 Jun 2017, 19:35

I'm interested in a repeating macro, that will probably need to run by a script

Activates upon pressing "F2"
Does the following action
Holds "W"
presses "Ctrl"
presses "E"
and repeats these button presses once per second
Pressing F2 again would disable it

admin
Site Admin
Posts: 585
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Repeating macro

Post by admin » 25 Jun 2017, 19:52

Can't be done with hid/lua macros
Petr Medek
LUAmacros author

Zapp Brannigan
Posts: 2
Joined: 21 Dec 2018, 02:04

Re: Repeating macro

Post by Zapp Brannigan » 21 Dec 2018, 02:27

You can set this up with a script. However the holding a key and then repeating a press would likely be two separate chunks. The first section would look like this in lua:

Code: Select all

if event == "f2" then
	state = not state
	if state then
		PressKey("w")
	else
		ReleaseKey("w")
	end
end
I use this exact script for GTA (I set a G-key to hold e for my horn) and a few other games. The next section you would need help with, I myself am stuck on repeating/looping scripts.

Closest I could think of for you (as a full script) would be:

Code: Select all

if event == "f2" then
	state = not state
	if state then
		PressKey("w")
		while state do
		PressKey("lctrl"); PressKey("e"); Sleep(100); ReleaseKey("lctrl"); ReleaseKey("e"); Sleep(100);
	else
		ReleaseKey("w")
	end
end
When F2 is pressed this would then HOLD and lock "W" and then press left ctrl and almost simultaneously press "E" then wait 100 micro seconds (0.1 seconds) then release left ctrl and "E" then wait another 100ms before starting the loop again, and finally once F2 is pressed again it would release "W". I assume you want to walk forward continuously and frequently crouch and pick up an item in a game? HOWEVER do not use this without someone smarter than me fixing it. Currently it will keep running the loop section (lctrl and "E" spam) until you shut down your PC. I myself am still struggling to turn off the loops I make :/

Post Reply