Created
December 20, 2017 21:42
-
-
Save gbakeman/7244fb2c00c486204d2fc1dad92a42b3 to your computer and use it in GitHub Desktop.
Logitech Gaming Software F-key binding script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --[[ | |
| This allows you to bind any function-number key (F1-F24) to a "G" button on your mouse. | |
| To add a binding, insert a new element in the bindings table below and save this script. | |
| Script by tgp1994 (https://github.com/tgp1994) | |
| ]] | |
| local bindings = { | |
| G7 = "F13", | |
| G8 = "F14" | |
| } | |
| local function bind_mouseDown(arg) | |
| for k,v in pairs(bindings) do | |
| if k == arg then | |
| local bindGroup = string.sub(v, 1, 1) | |
| if bindGroup == "F" then | |
| local fKey = string.sub(v, 2) | |
| --OutputLogMessage("Pressing button F%s.\n", fKey) | |
| PressKey(88 + fKey) | |
| else | |
| OutputLogMessage("Mouse button '%s' has an unrecognized binding '%s'.\n", k, v) | |
| end | |
| end | |
| end | |
| end | |
| local function bind_mouseUp(arg) | |
| for k,v in pairs(bindings) do | |
| if k == arg then | |
| local bindGroup = string.sub(v, 1, 1) | |
| if bindGroup == "F" then | |
| --OutputLogMessage("Key up.\n") | |
| local fKey = string.sub(v, 2) | |
| ReleaseKey(88 + fKey) | |
| end | |
| end | |
| end | |
| end | |
| function OnEvent(event, arg) | |
| --OutputLogMessage("event = %s, arg = %s\n", event, arg) | |
| if event == "MOUSE_BUTTON_PRESSED" then | |
| bind_mouseDown("G"..arg) | |
| elseif event == "MOUSE_BUTTON_RELEASED" then | |
| bind_mouseUp("G"..arg) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey tgp1994, that script should use
(87 + fKey)instead of(88 + fKey), otherwise the Fkey returned is one too high. It'd only be a problem if someone tries to use F23, but then it would be a problem.Also, while you'd expect F24's value to just be one more than F23's 110, F24 won't work with this script as it's value is actually 118, so that's also a no go.
Actually taking a look back at the lua scripting ref, it looks like either I didn't understand it back when I came up with the idea, or logitech's updated their code, so it directly accepts fKeys as a Presskey arg. You could replace
local fKey = string.sub(v, 2)--OutputLogMessage("Pressing button F%s.\n", fKey)PressKey(88 + fKey)with just
PressKey(v)and it'll work.