Page 1 of 1

Launching games directly from Cheat Engine

Posted: Wed Jul 08, 2026 2:06 am
by HNI96

Since I'm too lazy to manually click to open cheat engine, launch the game, minimize the game, attach cheat engine to process, activate cheats, go back to game, I've decided to automate all that. After wasting time messing around with reg query to get game's exe file path from registry, I've realized I was severely over complicating stuff. Thus I came up with a simple script that should work in every game, allowing you to automatically launch the game when you open the cheat table. My knowledge of Lua is still very superficial, and I'm learning as I go, thus it's likely there are many areas where the script could be improved.

A quick explanation of what happens:
1) The first time the table is opened, nothing happens until the user attaches cheat engine to the game's process.
2) When a process is attached, onOpenProcess is executed, saving the game's file path and process name in the addresses of new memory records.
3) When the cheat table is opened again, it prompts the user if they want to launch the game.
4) Using the saved file's path and process name, and createProcess of course, cheat engine launches the game and attaches to the process.
5) After that you can create a favorite group of scripts that are automatically enabled, meaning you never have to minimize the game.

Code: Select all

local path_record = AddressList.getMemoryRecordByDescription('GAME PATH')
local name_record = AddressList.getMemoryRecordByDescription('PROCESS NAME')
local parent = AddressList.getMemoryRecordByDescription('START')

function launch_game(path, process_name)
  if not path then return 2 end
  createProcess(path)
  getMainForm().WindowState = 'wsMinimized'
  sleep(1000)

  local pid = getProcessIDFromProcessName(process_name)
  if pid then
    openProcess(pid)
  else
    return 1
  end
  return 0
end

local function get_path(pid)
  local modules = enumModules(pid)

  if modules and #modules > 0 then
     return modules[1].PathToFile
  end

  return nil
end

function onOpenProcess(processId)
  if not parent then
    parent = AddressList.createMemoryRecord()
    parent.Description = 'START'
    parent.IsGroupHeader = true
    parent.Options = '[moHideChildren]'
  end

  if not path_record then
    path_record = AddressList.createMemoryRecord()
    path_record.Description = 'GAME PATH'
    path_record.appendToEntry(parent)
  end
  path_record.Address = get_path(processId)

  if not name_record then
    name_record = AddressList.createMemoryRecord()
    name_record.Description = 'PROCESS NAME'
    name_record.appendToEntry(parent)
  end
  name_record.Address = process
end

if path_record and name_record then
  local response = messageDialog("Launch Game?", mtConfirmation, mbYes, mbNo)
  if response == mrYes then
    local game_path = path_record.Address
    local game_process = name_record.Address
    if launch_game(game_path, game_process) ~= 0 then
       showMessage('Failed to launch game')
    end
  end
end