-- Constants local path_record_descr = 'Game Path' local name_record_descr = 'Process Name' local header_descr = 'Autorun' function launch_game(path, process_name) if not path then return 2 end createProcess(path) 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 = header_descr parent.IsGroupHeader = true parent.Options = '[moHideChildren]' end if not path_record then path_record = AddressList.createMemoryRecord() path_record.Description = path_record_descr path_record.appendToEntry(parent) end path_record.Address = get_path(processId) if not name_record then name_record = AddressList.createMemoryRecord() name_record.Description = name_record_descr name_record.IsReadable = false name_record.appendToEntry(parent) end name_record.Address = process end createThread(function(t) -- Wait until the main form exists and has finished loading while (getMainForm() == nil) or (not getMainForm().Visible) do sleep(100) -- Sleep avoids freezing the Cheat Engine main thread end -- Once loaded, execute your instructions on the main thread safely t.synchronize(function() local path_record = AddressList.getMemoryRecordByDescription(path_record_descr) local name_record = AddressList.getMemoryRecordByDescription(name_record_descr) local parent = AddressList.getMemoryRecordByDescription(header_descr) if path_record and name_record then local game_path = path_record.Address local game_process = name_record.Address local message = string.format('Launch %s?', game_process) local response = messageDialog(message, mtConfirmation, mbYes, mbNo) if response == mrYes then if launch_game(game_path, game_process) ~= 0 then message = string.format('Failed to launch %s. Is the game path <%s> correct?', game_process, game_path) showMessage(message) end end end end) end)