How to Automatically Attach Cheat Engine to a Game with Lua

Opening a Cheat Engine table usually goes something like this:

  1. Open the table.
  2. Click the process icon.
  3. Find the game executable.
  4. Attach to it.
  5. Repeat tomorrow.
  6. Repeat forever.
  7. Begin wondering why computers cannot perform the one repetitive task computers were supposedly invented to perform.

Fortunately, they can.

Cheat Engine supports automatic process attachment, and you can embed the configuration directly inside a cheat table using Lua. Cheat Engine’s official documentation specifically provides getAutoAttachList() for maintaining a list of process names that Cheat Engine should automatically attach to.

For most tables, the entire solution can be one line.

Wait, what is Cheat Engine? Here you go, bro: What Is Cheat Engine, and How Does It Actually Work?

The Simple Auto-Attach Script

Open your cheat table in Cheat Engine and press:

Ctrl + Alt + L

This opens the Cheat Table Lua Script window, which is where Lua code saved with the table can be placed. The official Cheat Engine auto-attach tutorial uses this same method.

Add:

getAutoAttachList().add("Game.exe")

Replace:

Game.exe

with the actual executable name of your game.

For example:

getAutoAttachList().add("Cyberpunk2077.exe")

Save the cheat table. That is basically it.

The next time the table is opened, Cheat Engine adds that executable to its automatic-attachment list and can attach when the process becomes available. Cheat Engine exposes getAutoAttachList() specifically as a StringList containing process names used for automatic attachment.

No timers. No elaborate functions. No 37-line Lua masterpiece copied from a forum post written during the Obama administration.

Just one line.

How Do You Find the Correct EXE Name?

This is the only part that may require investigation. The executable name is not necessarily the same as the game title.

A game called: Super Dragon Obsidian Adventure

might actually run as:

SDOA-Win64-Shipping.exe

This is especially common with games built using engines that use standardised executable naming conventions.

The easiest method is simply to launch the game and check the normal Cheat Engine process list once. You can also check Windows Task Manager.

Make sure you identify the actual game process rather than:

  • The launcher
  • An updater
  • A crash reporter
  • An anti-cheat bootstrapper
  • Some other executable hanging around because modern games apparently need a small government bureaucracy to start

You can also check the game’s installation folder. However, there may be both launcher and game executables there, so make sure you are pointing to the correct .exe.

Once you know the correct process name, put it inside the Lua script.

What If the Game Is Not Running Yet?

This is where auto-attach becomes particularly convenient. You can open the cheat table before launching the game.

The executable has been added to Cheat Engine’s automatic-attachment list, so Cheat Engine can watch for that process rather than requiring you to manually select it afterward. This behaviour is the reason Cheat Engine’s own auto-attach tutorial recommends getAutoAttachList().add() as the simplest solution.

Your workflow becomes:

  1. Open the .CT file.
  2. Launch the game.
  3. Cheat Engine attaches when the process appears.
  4. Continue using the table.

For tables you use regularly, removing even one repetitive step is surprisingly pleasant. Human civilisation was built through automation. This is merely the slightly less prestigious branch of it.

Definitely related: How to Use Cheat Engine for the First Time: A Beginner’s Guide

Using Multiple Possible Process Names

Occasionally, the same game may have multiple executables depending on version or configuration. Since the auto-attach list is simply a list of process names, you can add more than one:

getAutoAttachList().add("Game.exe")
getAutoAttachList().add("Game-Win64-Shipping.exe")

This can be useful when maintaining a table across different releases, although you should still verify that your actual cheats remain compatible with those versions.

Automatically attaching successfully does not mean your pointers, AOB signatures, or scripts survived an update.

It merely means Cheat Engine successfully found the patient. Whether the surgery still works is another matter.

The Reusable Version

For a script you repeatedly copy between tables, you can make the process name easier to spot:

local gameProcess = "Game.exe"

getAutoAttachList().add(gameProcess)

Then every time you create a new table, you only need to change:

"Game.exe"

to the appropriate executable.

For example:

local gameProcess = "MyAwesomeGame.exe"

getAutoAttachList().add(gameProcess)

Functionally, this does essentially the same thing as the one-line version. But it makes the part you are supposed to edit considerably more obvious—which becomes helpful six months later.

The Script Worth Keeping

For most Cheat Engine users, this is all you need:

local gameProcess = "Game.exe"
getAutoAttachList().add(gameProcess)

Change the executable name, save it inside your cheat table with Ctrl + Alt + L, and the table can handle process attachment for you.

It is not the most spectacular Cheat Engine script. It will not make you immortal. It will not give you infinite ammunition. It will not turn a rusty sword into the Super Dragon Obsidian Ingot Diamond Blade of Financial Irresponsibility.

But if you regularly create your own cheat tables—or simply modify tables made by someone else—you will probably reuse this tiny piece of Lua far more often than many complicated cheats.

The best utility scripts are sometimes like that. They do not do something impressive. They simply remove one annoying click forever.

Yabes Elia

Yabes Elia

An empath, a jolly writer, a patient reader & listener, a data observer, and a stoic mentor