1. Forum
    1. Unresolved Threads
  2. Articles
  3. Members
    1. Recent Activities
    2. Users Online
    3. Team
    4. Search Members
  4. Blog
    1. Articles
  • Login
  • Register
  • Search
Blog Articles
  • Everywhere
  • Articles
  • Forum
  • Blog Articles
  • Pages
  • More Options
  1. StageTwo - Deine Wohlfühloase
  2. Blog
  3. FragSalat's Blog

How to abort macro's - Logitech Gaming

  • FragSalat
  • May 27, 2019 at 1:51 PM
  • 81,492 times read
  • 13 Comments
Contents [hideshow]
  1. Steps
    1. Open Logitech Gaming Software and navigate to the G-Key Modification
    2. For the macro's you want to be able to abort, remove the G-Key assignments by dragging the macro into the trash bin. In my case it is G5 with the Macro "Buff"
    3. Modify the script of your active profile (I bet in English the menu entry is called something like "Create Script"
    4. Insert the lua script

I'm already for a long time owner of logitech keyboards and mouses but to be honest I used their features quite rarely. From time to time i created macros for the G-Keys of my previous G15 but it never worked out so well. As my Logitech G15 keyboard were already over 10 years old and my Logitech G5 mouse had a break in the cable, my girlfriend were so nice to spend me a new Logitech G613 wireless keyboard and a Logitech G603 wireless Mouse to my birthday last year <3

Today I finally had some things I wanted to put on the G-Keys. One key got an assignment to mute my microphone and the other should get a macro to buff my character in the old MMORPG I started playing again :) This worked very nice but there was a problem! Once the macro started, I couldn't abort it and the enemy had enough time to kick my ass^^ After some Googling and some short playing around I got my solution and that's what I want to share with you now :) (finally eh :D)

To be able to abort the macro you have to modify the lua script of your current profile to start or stop the macro programmatically. Don't be afraid if you have no idea of programming, it's not that tricky this time :)

Steps

1. Open Logitech Gaming Software and navigate to the G-Key Modification

2. For the macro's you want to be able to abort, remove the G-Key assignments by dragging the macro into the trash bin. In my case it is G5 with the Macro "Buff"




3. Modify the script of your active profile (I bet in English the menu entry is called something like "Create Script"

4. Insert the lua script

Copy the following script and replace the content of the default script. If you have an own script you have to merge the code manually :)

Once the script is in the editor you have to add the key-macro assignment at line 7. For each assignment create a like like macros[5] = "Buff" which means G5 holds the macro "Buff".

When you have defined the assignment save the script and try it by pressing your G-Keys. The log below the editor should tell you what the script is doing :)

Code
local macros = {}

---------------------------------------------------------------
-- Edit this macro list like this
-- macro["G-KEY the macro should be assigned"] = "Macro name"
---------------------------------------------------------------
macros[5] = "Buff"


---------------------------------------------------------------
-- No need to touch here
---------------------------------------------------------------
local macroRunning = nil

function handleGKey(key)
    if (macros[key] ~= nil) then
        if (macroRunning == macros[key]) then
            OutputLogMessage("Stopping Macro: %s\n", macros[key]);
            macroRunning = nil
            AbortMacro()
        elseif (macroRunning == nil) then
            OutputLogMessage("Running Macro: %s\n", macros[key]);
            macroRunning = macros[key]
            PlayMacro(macros[key])
        else
            OutputLogMessage("Another macro is running: %s\n", macroRunning);
        end
    end
end

function OnEvent(event, arg)
    if (event == "G_PRESSED") then
        handleGKey(arg)
    end
end
Display More


I hope that helps some people and please feel free to give me feedback on the blog post or the script itself :)

  • logitech
  • macro
  • lua

Previous Article Building an air quality sensor 433MHz and Raspberry PI

Next Article How to control IKEA Ansluta with Raspberry PI

Comments 13

pelux
October 10, 2025 at 5:09 PM
  • Report Content

I know this is old :) but I added some bells and whistles to the OG script.
You can assign macros to keyboard or mouse G keys.
You can assign each as either a Toggle (default) or Hold.
You can assign a dedicated "abort" key that will stop any running macro (provided that it was started by the script in the first place.)
Attempting to start a second macro will end the currently running macro and start the new one.
There are debug flags for outputting the pressed key to the console to help identify your keys. (set log_events or log_unmapped to "true".)

https://github.com/PeluxGit/Logit…ntroller-Script

Guziec
October 27, 2024 at 3:34 PM
  • Report Content

Are you still there?

Dreamer4k
November 7, 2019 at 8:07 PM
  • Report Content

So, i copied the Script. I've changed the relevant parts of your script from your [Macro5] to mine [Macro1], where i want it to be. Then theres the red error bar (Bug bar?) showing up.
Here's a link to the screenshot i took: https://imgur.com/a/DajRmXo
How can i fix this? Thanks for helping in advance.

FragSalat
November 8, 2019 at 11:11 AM
Author
  • Report Content

Is there any error message in the field visible or when you hover with the mouse over the line? I may can check that on the weekend.

Dreamer4k
November 9, 2019 at 9:49 AM
  • Report Content

It only says "Syntax Error" in line 11

FragSalat
November 10, 2019 at 8:43 PM
Author
  • Report Content

Ok I found the issue in your script. Line 11 has the parameter with the name '1' That is not valid. Please check against the script I posted. The parameter is key and it is used like 'macros[key]' and not like in your version 'macros1'. The script also mentioned to don't touch the area below :) Please again copy the script I posted and only change line 7 to 'macros[1] = "AutoSprint"' (without ')

Dreamer4k
November 13, 2019 at 9:52 AM
  • Report Content

So, i tried. But still it doesn't work like it should. As you said, i only changed the upper line and didn't change the lines underneath. In testing, there were no reactions to it. Did i do something wrong in changing your "Macros[5]" in my "Macros[1]"? What should i do?

FragSalat
November 13, 2019 at 10:28 AM
Author
  • Report Content

Can you please show me the current script? Does the Macro with the name you used after macros[1] = "MACRONAME" already exist?
I hope that you didn't used upper case Macros[1] but macros[1] :)

Categories

  • Default Category

Archive

  1. 2019 (4)
    1. September (1)
    2. May (1)
      • How to abort macro's - Logitech Gaming
    3. March (1)
    4. February (1)
  2. 2018 (7)
    1. August (1)
    2. June (2)
    3. May (3)
    4. April (1)
  3. 2017 (2)
    1. October (2)
  1. Privacy Policy
  2. Legal Notice