-
-
Save ewauq/2702c6b2342517a0ec9206fa101d3d7c to your computer and use it in GitHub Desktop.
| -- How to use this script: | |
| -- 1. Install the Logitech Gaming Software: http://support.logitech.com/en_us/software/lgs | |
| -- 2. Launch it, and right click on your profile (the gear icon) and then click on "Scripts". | |
| -- 3. Add the following code into the Script window, save it, and close it. Enjoy. | |
| -- Now G1 is bound to F13, G2 to G14, ... G12 to F24. | |
| function OnEvent(event, arg) | |
| -- OutputLogMessage("event = %s, arg = %s\n", event, arg) | |
| fKey = { | |
| [1] = 0x64, -- F13 | |
| [2] = 0x65, -- F14 | |
| [3] = 0x66, -- F15 | |
| [4] = 0x67, -- F16 | |
| [5] = 0x68, -- F17 | |
| [6] = 0x69, -- F18 | |
| [7] = 0x6A, -- F19 | |
| [8] = 0x6B, -- F20 | |
| [9] = 0x6C, -- F21 | |
| [10] = 0x6D, -- F22 | |
| [11] = 0x6E, -- F23 | |
| [12] = 0x76 -- F24 | |
| } | |
| if (event == "G_PRESSED") then | |
| PressKey(fKey[arg]) | |
| end | |
| if (event == "G_RELEASED") then | |
| ReleaseKey(fKey[arg]) | |
| end | |
| end |
This is fantastic! Does it go any higher than f24 or is that the limit? I'm trying to fill out my g13 with empty function keys
I am not sure, but I don't think there is more than 24 function keys.
Thank you, I wasn't sure either. I wish there was lol
While this was extremely helpful in the past with Logi Gaming Software since it lacked bindings like this without scripting, it is no longer needed with Logi G Hub. You can now bind F13 through F24 through the UI to any of the G keys.
Those of you who use Gaming Software should remove it. It has been abandoned in favor of G Hub. It's last update was 2018-10-08. Newer devices are unsupported and Logitech no longer offers customer assistance with this software. They instead direct you to G Hub.
What if I want to do this same thing to my G600 mouse. Those G keys are G9-G20
Those of you who use Gaming Software should remove it. It has been abandoned in favor of G Hub.
Has it improved any? Last time I used it, I lost all the profiles I'd set up after a reboot, so I immediately switched back to LGS, which still works fine with the occasional hiccup.
Has it improved any?
It has improved a lot since my comment. Logitech Gaming Software (LGS) profiles are stored at C:\Users\<name>\Appdata\Local\Logitech\Logitech Gaming Software\Profiles.
- Make sure LGHUB isn't installed at this time. Only LGS.
- Copy the
Logitechfolder fromAppDatato temporary location (Desktop for example). - Uninstall LGS and reboot.
- Copy the
Logitechfolder back toAppData. - Install LGHUB.
- From the LGHUB interface, click the cog/gear icon top right.
- Click "Import Profiles"
- LGHUB will find and import + convert LGS profiles to be usable with LGHUB.
Note: Some devices are not supported in LGHUB and those device specific settings in profiles will not carry over.
does LGHUB support the g710+?
I guess then the effort I put in yesterday was worth it. See this gist for anyone who wants a demonstration on targeting a specific M-profile and only one G-key.
https://gist.github.com/Thespikedballofdoom/569c3516ad83b008d4204ba7140b9751
This code won't work for mouse such as the G600. For those who want to implement this on a mouse, use the following new and greatly improved code:
-- How to use this script:
-- 1. Install the Logitech Gaming Software: http://support.logitech.com/en_us/software/lgs
-- 2. Launch it, and right click on your profile (the gear icon) and then click on "Scripts".
-- 3. Add the following code into the Script window, save it, and close it. Enjoy.
-- Now G9 on your G600 mouse is bound to F13, G10 to G14, ... G12 to F24.
function OnEvent(event, arg)
-- Enable logging
EnablePrimaryMouseButtonEvents(true)
-- Table mapping mouse button numbers to F-key hex codes
local fKeys = {
[9] = 0x64, -- F13
[10] = 0x65, -- F14
[11] = 0x66, -- F15
[12] = 0x67, -- F16
[13] = 0x68, -- F17
[14] = 0x69, -- F18
[15] = 0x6A, -- F19
[16] = 0x6B, -- F20
[17] = 0x6C, -- F21
[18] = 0x6D, -- F22
[19] = 0x6E, -- F23
[20] = 0x76, -- F24
}
-- Debug function to get F-key name from hex code
local function getFKeyName(hexCode)
for i, code in pairs(fKeys) do
if code == hexCode then
return "F" .. (i + 4) -- Adjusted to start from F13
end
end
return "Unknown"
end
-- Function to handle key press and release
local function handleKey(keyAction)
if fKeys[arg] then
local fKeyHex = fKeys[arg]
local fKeyName = getFKeyName(fKeyHex)
local actionName = keyAction == PressKey and "Pressing" or "Releasing"
OutputLogMessage("Mouse button %d: %s %s (Hex: 0x%02X)\n", arg, actionName, fKeyName, fKeyHex)
keyAction(fKeyHex)
else
OutputLogMessage("Unhandled mouse button: %d\n", arg)
end
end
OutputLogMessage("Event: %s, Arg: %d\n", event, arg)
if event == "MOUSE_BUTTON_PRESSED" then
handleKey(PressKey)
elseif event == "MOUSE_BUTTON_RELEASED" then
handleKey(ReleaseKey)
end
end
Old Logitech Keyboard and software user and this worked great, thank you. I then used the binds themselves to update the labels in the software too.
Export the configuration file, add the following code, and then import it. And so on. You can add any buttons you like without affecting the original functions.
<macro guid="{F13_GUID}" color="4278246655" name="F13" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F13"/> </keystroke> </macro> <macro guid="{F14_GUID}" color="4278246655" name="F14" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F14"/> </keystroke> </macro> <macro guid="{F15_GUID}" color="4278246655" name="F15" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F15"/> </keystroke> </macro> <macro guid="{F16_GUID}" color="4278246655" name="F16" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F16"/> </keystroke> </macro> <macro guid="{F17_GUID}" color="4278246655" name="F17" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F17"/> </keystroke> </macro> <macro guid="{F18_GUID}" color="4278246655" name="F18" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F18"/> </keystroke> </macro> <macro guid="{F19_GUID}" color="4278246655" name="F19" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F19"/> </keystroke> </macro> <macro guid="{F20_GUID}" color="4278246655" name="F20" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F20"/> </keystroke> </macro> <macro guid="{F21_GUID}" color="4278246655" name="F21" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F21"/> </keystroke> </macro> <macro guid="{F22_GUID}" color="4278246655" name="F22" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F22"/> </keystroke> </macro> <macro guid="{F23_GUID}" color="4278246655" name="F23" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F23"/> </keystroke> </macro> <macro guid="{F24_GUID}" color="4278246655" name="F24" hidden="false" original="true"> <keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke"> <key value="F24"/> </keystroke> </macro>
None of this worked on my G700s mouse. I did the following script to test ALL the keys, nothing worked.
BTW you can pass the keys as a string. Can just do "F19" for example. If the string is invalid, it'll throw an actual error.
Just because it's valid though doesn't mean it'll do anything.
counter = 0
function OnEvent(event, arg)
-- ## Microsoft's actual standard VKEY codes
-- keymap = {
-- [5] = 0x82, -- F19
-- [7] = 0x83, -- F20
-- [8] = 0x84, -- F21
-- [9] = 0x85, -- F22
-- [10] = 0x86, -- F23
-- [11] = 0x87 -- F24
-- }
-- ## The codes mentioned on https://gist.github.com/ewauq/2702c6b2342517a0ec9206fa101d3d7c
-- local keymap = {
-- [5] = 106, -- F19
-- [7] = 107, -- F20
-- [8] = 108, -- F21
-- [9] = 109, -- F22
-- [10] = 110, -- F23
-- [11] = 118 -- F24
-- }
-- You can apparently pass the key as a string
local keymap = {
[5] = "F19", -- F19
[7] = "F20", -- F20
[8] = "F21", -- F21
[9] = "F22", -- F22
[10] = "F23", -- F23
[11] = "F24" -- F24
}
if arg == 11 then
counter = counter + 1
if event == "MOUSE_BUTTON_PRESSED" then
OutputLogMessage("TEST KeyDN: %s mapto: %i \t0x%X \n", arg, counter, counter)
PressKey(counter)
elseif event == "MOUSE_BUTTON_RELEASED" then
OutputLogMessage("TEST KeyUP: %s mapto: %i \t0x%X \n", arg, counter, counter)
ReleaseKey(counter)
end
else
local keyval = keymap[arg]
if keyval then
if event == "MOUSE_BUTTON_PRESSED" then
-- OutputLogMessage("KeyDN: %s mapto: %i \t0x%X \n", arg, keyval, keyval)
OutputLogMessage("KeyDN: %s mapto: %s\n", arg, keyval)
PressKey(keyval)
elseif event == "MOUSE_BUTTON_RELEASED" then
-- OutputLogMessage("KeyUP: %s mapto: %i \t0x%X \n", arg, keyval, keyval)
OutputLogMessage("KeyUP: %s mapto: %s\n", arg, keyval)
ReleaseKey(keyval)
end
end
end
end- Invalid Keys (these throw an exception):
85,89-92,94-99,111,113,114,116,117,122,124,127-240,253-271,273-280,282-287,291,293-301,303,305,307,308,310,313-324,330,332,334,340-346,350-363,366-872
I got tired of clicking at 872. - Key combinations that don't throw an exception (but nothing special happens)
86-88,93,100-110,112,115,118-121,123,125,126,241-252,272,281,284,285,288-290,292,302,304,306,309,311,312,325-329, 331,333,335-339,347-349,364-365- None of the valid keys ever pressed a keyboard key or Fkey.
- KeyboardStateView never registered keypress's beyond some media keys, VK_LAUNCH_APP, VK_OEM_4, VK_OEM6, and VK_OEM2
- VSCode's "Keyboard Shortcuts" menu with Search by key or Record Keys never picked anything up
- None of the valid keys ever pressed a keyboard key or Fkey.
- Notes:
288-290: One of these keys opened Calculator / VK_LAUNCH_APP2364-365: One of thse opened Media Player / VK_LAUNCH_MEDIA_SELECT
WEW!! I GOT IT WORKING.
The trick was to use a Hardware Profile burned into the mouse.
g700s-FKeys.dat
Placed in %LOCALAPPDATA%\Logitech\Logitech Gaming Software\Logitech Gaming Software\On-Board Profiles\G700s\g700s-FKeys.dat
<?xml version="1.0" encoding="utf-8"?>
<obprofiles xmlns="http://www.logitech.com/Cassandra/2013.1/OnboardProfile">
<profile name="g700s-FKeys">
<device powermode="3" buttoncount="13" model="Logitech.Gaming.Mouse.G700s" reportrate="1000" anglesnapping="0">
<dpitable defaultindex="0">
<dpi x="1600" y="1600"/>
<dpi x="0" y="0"/>
<dpi x="0" y="0"/>
<dpi x="0" y="0"/>
<dpi x="0" y="0"/>
</dpitable>
</device>
<buttons>
<button number="1" name="Left Click">
<mousefunction xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/MouseFunction">
<do task="leftclick"/>
</mousefunction>
</button>
<button number="2" name="Right Click">
<mousefunction xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/MouseFunction">
<do task="rightclick"/>
</mousefunction>
</button>
<button number="3" name="Middle Click">
<mousefunction xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/MouseFunction">
<do task="middleclick"/>
</mousefunction>
</button>
<button number="4" name="Back">
<mousefunction xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/MouseFunction">
<do task="back"/>
</mousefunction>
</button>
<button number="5" name="Dismiss">
<!-- Implemented via Autohotkey:
- If popup or dialog window has a preselected button matching text
`(OK|Accept|Next|Submit|Continue|Enter|Dismiss|Cancel|Close|Abort)` send the '{ENTER}' key,
else send '{ESCAPE}' key
- If tabs detected, send Ctrl+W to close the tab
- Otherwise send close window message to the active window
-->
<keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke">
<key value="F19" />
</keystroke>
</button>
<button number="6" name="Forward">
<mousefunction xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/MouseFunction">
<do task="forward"/>
</mousefunction>
</button>
<button number="7" name="CycleLeft Window Positions">
<!-- Implemented via DisplayFusion -->
<keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke">
<key value="F20" />
</keystroke>
</button>
<button number="8" name="NextTab/TabRight or PageDown">
<!-- Implemented via Autohotkey that detects when windows have tabs -->
<keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke">
<key value="F21" />
</keystroke>
</button>
<button number="9" name="PriorTab/TabLeft or PageUp">
<!-- Implemented via Autohotkey that detects when windows have tabs -->
<keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke">
<key value="F22" />
</keystroke>
</button>
<button number="10" name="CycleRight Window Positions">
<!-- Implemented via DisplayFusion -->
<keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke">
<key value="F23" />
</keystroke>
</button>
<button number="11" name="Cycle Window Size">
<!-- Implemented via DisplayFusion -->
<keystroke xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/Keystroke">
<key value="F24" />
</keystroke>
</button>
<button number="12" name="Scroll Left">
<mousefunction xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/MouseFunction">
<do task="scrollleft"/>
</mousefunction>
</button>
<button number="13" name="Scroll Right">
<mousefunction xmlns="http://www.logitech.com/Cassandra/2010.1/Macros/MouseFunction">
<do task="scrollright"/>
</mousefunction>
</button>
</buttons>
</profile>
</obprofiles>None of this worked on my G700s mouse. I did the following script to test ALL the keys, nothing worked.
BTW you can pass the keys as a string. Can just do "F19" for example. If the string is invalid, it'll throw an actual error. Just because it's valid though doesn't mean it'll do anything.
counter = 0 function OnEvent(event, arg) -- ## Microsoft's actual standard VKEY codes -- keymap = { -- [5] = 0x82, -- F19 -- [7] = 0x83, -- F20 -- [8] = 0x84, -- F21 -- [9] = 0x85, -- F22 -- [10] = 0x86, -- F23 -- [11] = 0x87 -- F24 -- } -- ## The codes mentioned on https://gist.github.com/ewauq/2702c6b2342517a0ec9206fa101d3d7c -- local keymap = { -- [5] = 106, -- F19 -- [7] = 107, -- F20 -- [8] = 108, -- F21 -- [9] = 109, -- F22 -- [10] = 110, -- F23 -- [11] = 118 -- F24 -- } -- You can apparently pass the key as a string local keymap = { [5] = "F19", -- F19 [7] = "F20", -- F20 [8] = "F21", -- F21 [9] = "F22", -- F22 [10] = "F23", -- F23 [11] = "F24" -- F24 } if arg == 11 then counter = counter + 1 if event == "MOUSE_BUTTON_PRESSED" then OutputLogMessage("TEST KeyDN: %s mapto: %i \t0x%X \n", arg, counter, counter) PressKey(counter) elseif event == "MOUSE_BUTTON_RELEASED" then OutputLogMessage("TEST KeyUP: %s mapto: %i \t0x%X \n", arg, counter, counter) ReleaseKey(counter) end else local keyval = keymap[arg] if keyval then if event == "MOUSE_BUTTON_PRESSED" then -- OutputLogMessage("KeyDN: %s mapto: %i \t0x%X \n", arg, keyval, keyval) OutputLogMessage("KeyDN: %s mapto: %s\n", arg, keyval) PressKey(keyval) elseif event == "MOUSE_BUTTON_RELEASED" then -- OutputLogMessage("KeyUP: %s mapto: %i \t0x%X \n", arg, keyval, keyval) OutputLogMessage("KeyUP: %s mapto: %s\n", arg, keyval) ReleaseKey(keyval) end end end end
Invalid Keys (these throw an exception):
85,89-92,94-99,111,113,114,116,117,122,124,127-240,253-271,273-280,282-287,291,293-301,303,305,307,308,310,313-324,330,332,334,340-346,350-363,366-872
I got tired of clicking at 872.Key combinations that don't throw an exception (but nothing special happens)
86-88,93,100-110,112,115,118-121,123,125,126,241-252,272,281,284,285,288-290,292,302,304,306,309,311,312,325-329, 331,333,335-339,347-349,364-365
None of the valid keys ever pressed a keyboard key or Fkey.
- KeyboardStateView never registered keypress's beyond some media keys, VK_LAUNCH_APP, VK_OEM_4, VK_OEM6, and VK_OEM2
- VSCode's "Keyboard Shortcuts" menu with Search by key or Record Keys never picked anything up
Notes:
288-290: One of these keys opened Calculator / VK_LAUNCH_APP2364-365: One of thse opened Media Player / VK_LAUNCH_MEDIA_SELECT
Should of tried my code, which uses the hex code to get the keys:
-- How to use this script:
-- 1. Install the Logitech Gaming Software: http://support.logitech.com/en_us/software/lgs
-- 2. Launch it, and right click on your profile (the gear icon) and then click on "Scripts".
-- 3. Add the following code into the Script window, save it, and close it. Enjoy.
-- Now G9 on your G600 mouse is bound to F13, G10 to G14, ... G12 to F24.
function OnEvent(event, arg)
-- Enable logging
EnablePrimaryMouseButtonEvents(true)
-- Table mapping mouse button numbers to F-key hex codes
local fKeys = {
[9] = 0x64, -- F13
[10] = 0x65, -- F14
[11] = 0x66, -- F15
[12] = 0x67, -- F16
[13] = 0x68, -- F17
[14] = 0x69, -- F18
[15] = 0x6A, -- F19
[16] = 0x6B, -- F20
[17] = 0x6C, -- F21
[18] = 0x6D, -- F22
[19] = 0x6E, -- F23
[20] = 0x76, -- F24
}
-- Debug function to get F-key name from hex code
local function getFKeyName(hexCode)
for i, code in pairs(fKeys) do
if code == hexCode then
return "F" .. (i + 4) -- Adjusted to start from F13
end
end
return "Unknown"
end
-- Function to handle key press and release
local function handleKey(keyAction)
if fKeys[arg] then
local fKeyHex = fKeys[arg]
local fKeyName = getFKeyName(fKeyHex)
local actionName = keyAction == PressKey and "Pressing" or "Releasing"
OutputLogMessage("Mouse button %d: %s %s (Hex: 0x%02X)\n", arg, actionName, fKeyName, fKeyHex)
keyAction(fKeyHex)
else
OutputLogMessage("Unhandled mouse button: %d\n", arg)
end
end
OutputLogMessage("Event: %s, Arg: %d\n", event, arg)
if event == "MOUSE_BUTTON_PRESSED" then
handleKey(PressKey)
elseif event == "MOUSE_BUTTON_RELEASED" then
handleKey(ReleaseKey)
end
end
In your case, you would adapt the code to be as such due the lower number of buttons:
-- How to use this script:
-- 1. Install the Logitech Gaming Software: http://support.logitech.com/en_us/software/lgs
-- 2. Launch it, and right click on your profile (the gear icon) and then click on "Scripts".
-- 3. Add the following code into the Script window, save it, and close it. Enjoy.
-- Now G4 on your G700 mouse is bound to F13, G5 to F14, ... G11 to F20.
function OnEvent(event, arg)
EnablePrimaryMouseButtonEvents(true)
-- Table mapping G700 button numbers to F-key hex codes
-- G700 has buttons G4–G11 (8 programmable buttons)
local fKeys = {
[4] = 0x64, -- F13
[5] = 0x65, -- F14
[6] = 0x66, -- F15
[7] = 0x67, -- F16
[8] = 0x68, -- F17
[9] = 0x69, -- F18
[10] = 0x6A, -- F19
[11] = 0x6B, -- F20
}
local function getFKeyName(hexCode)
for i, code in pairs(fKeys) do
if code == hexCode then
return "F" .. (i + 9) -- G4 → F13, G5 → F14, etc.
end
end
return "Unknown"
end
local function handleKey(keyAction)
if fKeys[arg] then
local fKeyHex = fKeys[arg]
local fKeyName = getFKeyName(fKeyHex)
local actionName = keyAction == PressKey and "Pressing" or "Releasing"
OutputLogMessage("Mouse button %d: %s %s (Hex: 0x%02X)\n", arg, actionName, fKeyName, fKeyHex)
keyAction(fKeyHex)
else
OutputLogMessage("Unhandled mouse button: %d\n", arg)
end
end
OutputLogMessage("Event: %s, Arg: %d\n", event, arg)
if event == "MOUSE_BUTTON_PRESSED" then
handleKey(PressKey)
elseif event == "MOUSE_BUTTON_RELEASED" then
handleKey(ReleaseKey)
end
end




Thank you so much this is exactly what I was looking for!