I have this lua and it worked just fine back in may, then yesterday I came back to test it out after several months not used, and now, nothing, did anything change in Ghub/Lua?
This is the script:
function OnEvent(event, arg)
OutputLogMessage("event = %s, arg = %d\n", event, arg)
if (event == "PROFILE_ACTIVATED") then
EnablePrimaryMouseButtonEvents(true)
elseif event == "PROFILE_DEACTIVATED" then
ReleaseMouseButton(2) -- to prevent it from being stuck on
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 7) then
recoil = not recoil
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil) then
if recoil then
repeat
Sleep(18)
MoveMouseRelative(0,2)
until not IsMouseButtonPressed(1)
end
end
end
I tried reinstalling Logitech Ghub several times including reboots, nothing changed.
EDIT I added this at the top of my script, and it seems to have done the trick.
EnablePrimaryMouseButtonEvents(true);
In the current version of GHub the
PROFILE_ACTIVATEDevent has its second parameterarg=nil(in the previous versionsargwas0), so you must replacewith either
or
Without such modification, all your GHub scripts now fail to handle events
PROFILE_ACTIVATEDandPROFILE_DEACTIVATEDas the code generates an exception at the lineOutputLogMessage.