Search code examples
lualogitech-gaming-software

Logitech G910 how to make Lua script only run on M3 G keys


I have a logitech G910 keyboard which has 9 G-keys and 3 "M-key" sets for a total of 27

I have a script that i have linked to G1 key but i have other macros on M1 set and M2 set, I only want the scripts to activate if on M3 set. Is there anyway to add something to specify that. This is one of the scripts I have

 if (event == "G_PRESSED" and arg == 1) then
        MoveMouseTo( 63076, 53509)
        Sleep(150)
        PressMouseButton(3)      
        ReleaseMouseButton(3)
        Sleep(150)
        MoveMouseTo( 60583, 56728)
        Sleep(150)
        PressMouseButton(1)      
        ReleaseMouseButton(1)
    end

I tried to add in there something like if (event == "M3_ACTIVE" and "G_PRESSED" and arg == 1) then or if (event == "M3_PRESSED" and "G_PRESSED" and arg == 1) then

but Im only very new to scripting and just googled what I wanted so no idea :D


Solution

  • You can call GetMKeyState("kb") to get the current M key number.

    if event == "G_PRESSED" and arg == 1 and GetMKeyState("kb") == 3 then