luakeyboardlogitechlogitech-gaming-software

lua script problem for logitech g512 keyboard


i want to implement this lua script which was posted by "Egor Skriptunoff" in a previous thread of mine into my logitech g512 keyboard. Lua script loop keys press

The thing is i tried some modifications like this one, which is to replace (MOUSE_BUTTON_PRESSED) with (G_PRESSED) because my keyboard has f1-f12 g keys but nothing works. Any solution?

local keys = {"5", "6", "7"}   -- cycle of keys
local idx = 0
local tm = -math.huge

function OnEvent(event, arg, kb)
if event == "G_PRESSED" and arg == 2 then
      if GetRunningTime() - tm > 1000 then
         idx = 0
      end
      idx = idx % #keys + 1
      PressKey(keys[idx])
   elseif event == "G_RELEASED" and arg == 2 then
      ReleaseKey(keys[idx])
      tm = GetRunningTime()
   end
end

Solution

  • The script is OK.
    The problem is with GHUB - it does not generate G-key events until you bind a non-standard macro to it.
    So, create a macro "Press F2 - wait 50 ms - Release F2" and assign it to G2 in GHUB (to save the original function of the key). Do not bind standard "F2" macro!
    After that your script will work.