Touching up my LUA with my first big problem!

Parker Williamson
3 min readMar 30, 2021

I continued on my LUA Script fun this week, and to be honest, it is pretty consuming. In my mind, consuming is not a negative thing for something I am practicing though. I absolutely love feeling the need to go to my computer to learn more about coding, and being passionate about learning what to do next and how to solve an issue. Right now, my issue is my mouse. I am trying to use the Logitech API guide for the LUA script syntax, but the guide is not quite right. So I am doing a trial and error style approach, and just reading a little bit more this week.

The original script for a Logitech non-gaming mouse is working correctly, which I had gotten from a friend-

function OnEvent(event, arg, mouse)
if (event == "MOUSE_BUTTON_PRESSED" and arg == 6) then
repeat
--x, y = GetMousePosition()
--OutputLogMessage("Mouse is at %d, %d\n", x, y)
PressKey ("escape")
ReleaseKey ("escape")
PressKey ("up")
ReleaseKey ("up")
PressKey ("enter")
ReleaseKey ("enter")
until IsMouseButtonPressed(6)
end
end

According to the LUA guide from Logitech, MOUSE_BUTTON_PRESSED should be changed to G_PRESSED with the argument of the button in question, but that is not working. Also, instead of the IsMouseButtonPressed, it should be IsGPressed. None of these fixes are working, and when I reassign anything to my mouse, the loop refuses to close and crashes my computer if I do not restart rather quickly. The code I am currently trying is-

function OnEvent(event, arg, mouse)
if (event == "MOUSE_BUTTON_PRESSED" and arg == 9) then
repeat
--x, y = GetMousePosition()
--OutputLogMessage("Mouse is at %d, %d\n", x, y)
PressKey ("escape")
ReleaseKey ("escape")
PressKey ("up")
ReleaseKey ("up")
PressKey ("enter")
ReleaseKey ("enter")
until IsMouseButtonPressed(9)
end
end
--Currently not working
--event == "G_PRESSED" and arg == 9
--until IsGPressed(9)

I changed the G_PRESSED to MOUSE_BUTTON_PRESSED due to something I found online, but this did not fix the issue. I guess it is back to the drawing board for me and my LUA learning, but it has definitely been a fun project. I did choose to email the Logitech Support to see if I can get an upgraded guide on my Logitech G-600 mouse with appropriate assignments for the extra buttons on the side, because I think that will help a lot. I could end up writing something that will return a printed line of ‘Button (x) was pressed.’ and assign that to buttons 1–20, and see what it returns, but that is another project of learning which could be a fun troubleshooting step.

I may also reach out to someone who knows LUA to see if there is an easier way to troubleshoot this and see if there is a better way than running 20 different functions for different button pressed, but hey, it would be good practice!

For reference, the guide I have been referring to is https://www.logitech.com/assets/44964/3/g600-mmo-gaming-mouse-quickstart-guide.pdf which is my current mouse, but there are multiple articles stating that the different assignments according to that guide are incorrect, and that finding out which buttons do what may be more beneficial, because they did not post their results.

It could have to do with different buttons being assigned to keys through the software which is why they choose not to post it, but I will wait to hear back from Logitech and see what they think about the issue. I am hoping they get back rather quickly because I am itching to fix this issue!

--

--