Logitech G HUB Macro Guide

How to Set Up Macros and Lua Scripts in Logitech G HUB

Set up standard mouse macros, assign them to Logitech buttons, and use Lua scripts for more advanced G HUB configurations.

Basics

Logitech G HUB Macros vs Lua Scripts

Logitech G HUB supports two different macro setup methods. The first method is the standard macro editor, where you create a fixed sequence of actions such as clicks, key presses, delays, holds, and releases. This is similar to how macros work in Razer Synapse and Bloody Esports.

The second method is Lua scripting. Lua scripts are more advanced because they can use custom logic, timing, conditions, loops, and randomized delays.

This is where Logitech G HUB has a real advantage. Lua scripts can be written with variable timing, so repeated actions do not have to use the exact same delay every time. This creates more human-like behavior than a fixed macro sequence.

Step by Step

How to Create and Assign a Macro in Logitech G HUB

This section shows the basic Logitech G HUB macro workflow.

  1. Open Logitech G HUB and select your device.
    Logitech G HUB devices screen showing G502 HERO mouse and G213 keyboard connected
    Start from the Logitech G HUB Devices tab and select the mouse you want to configure
  2. In the left-side menu, open Assignments, then select the Macros section.
    Logitech G HUB G502 HERO assignments screen with the Macros tab and Create New Macro button
    Open the G502 HERO Assignments panel, select Macros, and click Create New Macro
  3. Click Create New Macro and give it a clear name, such as Run, then choose how the macro should work, for example Toggle.
    Logitech G HUB macro type selection screen with Toggle mode highlighted for a macro named Run
    Choose the macro playback type. In this example, the Run macro uses Toggle mode
    • No Repeat - the macro runs once after you press the assigned button.
    • Repeat While Holding - the macro keeps running while the assigned button is held.
    • Toggle - one press starts the macro, and the next press stops it.
    • Sequence - separate macro stages can run on press, while holding, and on release.
  4. Click Start Now, then choose an option such as Record Keystroke.
    Logitech G HUB macro editor showing action options such as Record Keystrokes, Text & Emojis, Action, Launch Application, System, and Delay
    Use the macro editor to add keystrokes, actions, system commands, application launches, or delays
    • Record Keystroke - records keyboard inputs, mouse clicks, and scroll actions.
    • Text & Emojis - creates a text or emoji input that can be inserted with one button press.
    • Action - assigns a supported action for a compatible game or application.
    • Launch Application - starts a selected program or game.
    • System - assigns one or more system-level actions.
    • Delay - adds custom timing between macro actions.
  5. Select Record Keystroke, press and release the W key, then stop recording. If needed, uncheck Use Standard Delays to set the delay manually.
    Logitech G HUB macro editor showing W key actions with a 60 ms delay and Use Standard Delays disabled
    Disable standard delays to keep recorded input timing, such as the 60 ms delay shown between key actions

    Example sequence:

    W press -> 60 ms -> W release

    Click the Save button after the sequence is complete.

  6. Drag the macro from the Macros list and drop it onto the mouse button you want to use, such as Middle Click.
    Logitech G HUB G502 HERO assignments screen showing the Run macro assigned to the G3 mouse button
    Drag the created macro onto a mouse button to assign it. Here, the Run macro is assigned to the G3 button
  7. Make sure the correct G HUB profile is active. Macro assignments are profile-based, so using the wrong profile can make it look like the macro is missing.
Lua Script

How to Add a Lua Script in Logitech G HUB

This section shows how to open the G HUB scripting editor, create a new Lua script, add your code, and run it inside the selected Logitech profile.

  1. Open Logitech G HUB and go to the Profiles tab.
  2. In the active profile, look near the lower-left area of the profile details panel and click the rotating gear icon labeled Scripting.
    Logitech G HUB Profiles tab showing the Scripting button for the Desktop Default profile
    Open the Profiles tab, select the active profile, and click the Scripting button near Details
  3. In the Scripting window, click Create a new Lua script at the bottom, or select it from the active Lua script list at the top.
    Logitech G HUB Lua scripting screen showing the Create a New Lua Script button
    Click Create a New Lua Script to add a fresh Lua script to the selected profile
  4. Paste your Lua code into the editor or load a .lua file. Example:
    data = dofile[[D:\macro\file.lua]]
  5. Open the Script menu, click Save & Run, then close the window. The script should already contain its own control logic, such as enable, disable, toggle, button handling, or timing behavior.
    Logitech G HUB Lua script editor showing a new script with Save & Run and the script name edit button
    Rename the script if needed, paste your Lua code into the editor, then use Save & Run
Fixes

Common Logitech G HUB Macro and Lua Script Problems

The macro does not start

Make sure the macro is assigned to the correct mouse button and that Logitech G HUB is running.

The Lua script does not start
  1. The correct G HUB profile is not active.
  2. The script was added to the wrong profile.
  3. The app where you test the script is running as administrator, but G HUB is not.
The macro repeats incorrectly

Check the macro type. No Repeat, Repeat While Holding, Toggle, and Sequence work differently.

The timing feels wrong

Edit the delay values. Even small timing changes can affect how the macro feels.

FAQ

Logitech G HUB Macros and Lua Scripts FAQ

Quick answers about Logitech G HUB macros, Lua scripts, profiles, and editing.

What is the difference between a G HUB macro and a Lua script?

A standard G HUB macro is a fixed sequence of recorded actions, such as key presses, mouse clicks, delays, and releases. A Lua script can use logic, conditions, loops, custom timing, and variable delays.

Do I need to assign a Lua script to a mouse button?

Not always. A Lua script can listen for mouse button events directly if that logic is written inside the script. Standard macros usually need to be assigned to a specific button in G HUB.

Why does my macro or Lua script not work?

The most common reason is the wrong active profile. G HUB macros and scripts are profile-based, so make sure the correct game or desktop profile is active. Also check that the script is saved and running.

Can I edit G HUB macros and Lua scripts after creating them?

Yes. Standard macros can be edited inside the Macros section. Lua scripts can be edited inside the G HUB scripting editor, then saved and run again.