Skip to content

Instantly share code, notes, and snippets.

@MartinHarding
Last active October 28, 2023 10:35
Show Gist options
  • Save MartinHarding/3155be5e286e3f483223a1e21024c554 to your computer and use it in GitHub Desktop.
Save MartinHarding/3155be5e286e3f483223a1e21024c554 to your computer and use it in GitHub Desktop.
Logitech Gaming Software Mouse Button Toggle script
-- Toggles a mouse button when you press another mouse button.
-- 1. Change your mouse to "Automatic Game Detection" mode
-- 2. Right click on a profile's icon and choose scripting
-- 3. Paste this into the default profile script box, save, enjoy!
toggle_button = 7 -- What mouse button should control the toggle
button_to_toggle = 1 -- What button to toggle
button_toggled = false
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == toggle_button then
button_toggled = not button_toggled
OutputLogMessage("Mouse %d toggled %s", button_to_toggle, tostring(button_toggled))
if button_toggled then
PressMouseButton(button_to_toggle)
else
ReleaseMouseButton(button_to_toggle)
end
end
end
@Parzehlli
Copy link

I may figure this out on my own a few days from now cause im a noob, but man would help be appreciated greatly.

@johnwang16
Copy link

to find what buttons map to what number, use this in the script window and start pressing stuff

function OnEvent(event, arg)
	OutputLogMessage("event = %s, arg = %s\n", event, arg);
end

@Parzehlli
Copy link

to find what buttons map to what number, use this in the script window and start pressing stuff

function OnEvent(event, arg)
	OutputLogMessage("event = %s, arg = %s\n", event, arg);
end

Actually yeah i figured that out BUT! what if i don't even need the buttons mapped in the script cause the goal is only to have my left or right click held in. How bout a Toggle ON-OFF button for the left or right click mouse buttons held on. For example, i can just press J and the script is on and holding the left click in for me. Than when i want it off just press J again, Is that possible?

@johnwang16
Copy link

No, not with logitech scripting. https://douile.github.io/logitech-toggle-keys/APIDocs.pdf
AutoHotkey is what you want to use

@Parzehlli
Copy link

I figured it OUT! AutoHotKey can get you banned tho in some games? Here- for any future people who come across this your welcome! This is working in the LGS Software with a Logitech G502 or G502 Hero. Hmu for more details on what it does, thanks @johnwang16
"function OnEvent(event, arg)
if IsKeyLockOn ("capslock") then
if event == "MOUSE_BUTTON_PRESSED" and arg == 8 then
PressKey("B")
end
if event == "MOUSE_BUTTON_RELEASED" and arg == 2 then
ReleaseKey("B")
end
elseif IsMouseButtonPressed(3)then
repeat
if IsMouseButtonPressed(1) then
repeat
MoveMouseRelative(0,1)
Sleep(8)
until not IsMouseButtonPressed(1)
end
until not IsMouseButtonPressed(3)
end
end"

@evanricard
Copy link

Is there any way to apply this profile to a Logitech Ergo MX?

Copy link

ghost commented Jun 7, 2021

https://github.com/RavenBHK/DBD-Left-Hold-and-Auto-Run

I used to above macro and am trying to combine with this one. Can anyone help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment