[Is it possible to find a workaround for this I know that M and N are no G-Keys but I would like to to have two different key sequences depending on the last key input (either M or N). (I am a bloody beginner)
Thanks in advance!
I have no idea where to start to be honest.
-- Variable to track the last key pressed
local lastKeyPressed = nil
function OnEvent(event, arg)
if event == "G_PRESSED" then
if arg == 77 then -- Direct key code for "M"
lastKeyPressed = "m"
elseif arg == 78 then -- Direct key code for "N"
lastKeyPressed = "n"
end
end
-- Check if the scroll wheel button is pressed to activate the macro
if event == "MOUSE_BUTTON_PRESSED" and arg == 3 then -- Assuming middle mouse button (scroll wheel) is used
QP()
end
end
function QP()
local leanDuration = 25 -- Duration to hold lean in milliseconds
local pauseDuration = 40 -- Pause between actions in milliseconds
if lastKeyPressed == "n" then
-- If N was the last key, press M then N
PressKey("m")
Sleep(leanDuration)
ReleaseKey("m")
Sleep(pauseDuration)
PressKey("n")
Sleep(leanDuration)
ReleaseKey("n")
elseif lastKeyPressed == "m" then
-- If M was the last key, press N then M
PressKey("n")
Sleep(leanDuration)
ReleaseKey("n")
Sleep(pauseDuration)
PressKey("m")
Sleep(leanDuration)
ReleaseKey("m")
else
-- Default action if no key has been pressed yet (optional)
PressKey("n")
Sleep(leanDuration)
ReleaseKey("n")
Sleep(pauseDuration)
PressKey("m")
Sleep(leanDuration)
ReleaseKey("m")
end
lastKeyPressed = nil
end
](https://stackoverflow.com)
New contributor
thpii is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.