Foreword: I have never coded in LUA before so my code probably sucks and I'm probably doing something wrong.
I recently discovered the G-Shift function of LG mice, and decided to move my auto clicker to a G-Shift bound button (G-Shift + DPI-Shift (aka button 9 and button 6)). I also heard that creating an LUA script would make my auto clicker far faster than using their macros (not sure if that is true or not).
I went into my default profile and quickly coded up an auto clicker, but it didnt work. After a bunch of research and some help (mainly gemini and phind) I settled on this amalgamation:
local gShiftPressed = false
local dpiShiftPressed = false
local autoclicking = false
function OnEvent(event, arg)
--[[OutputLogMessage("Event: "..event.." Arg: "..arg.."")
Mouse Button 9 = GShift
Mouse Button 6 = DPI Shift--]]
if (event == "MOUSE_BUTTON_PRESSED") then
if (arg == 9) then
gShiftPressed = true
elseif (arg == 6) then
dpiShiftPressed = true
end
elseif (event == "MOUSE_BUTTON_RELEASED") then
if (arg == 9) then
gShiftPressed = false
elseif (arg == 6) then
dpiShiftPressed = false
end
end
if(gShiftPressed and dpiShiftPressed and not autoclicking) then
autoclicking = true
while(autoclicking == true) do
PressAndReleaseMouseButton(1)
if(not gShiftPressed and not dpiShiftPressed) then
autoclicking = false
end
end
end
end
I have 2 problems now:
1.) LG Ghub says I have a syntax error (I feel like I dont, but who knows)
2.) When my code was working, it would click continuously but never stop when i wanted it to
I tried thinking of an async solution, but i dont think Ghub supports Async coding