Lua:getOpenedProcessID

From Cheat Engine
Revision as of 00:44, 5 December 2025 by Leunsel (talk | contribs) (Added CodeBox Template.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
<> Function

function getOpenedProcessID() : Integer

Returns the process ID of the currently opened process in Cheat Engine. If no process is open, returns 0.

Note: getOpenedProcessID() does not return 0 after a process was closed. It will still return the previous ID, even if the process has been terminated. To check if the process is still available, use readInteger(process).

Function Parameters

<none>

Returns

Integer — The process ID of the currently opened process, or 0 if none.

Examples

local pid = getOpenedProcessID()
if pid ~= 0 then
  print("Current process ID:", pid)
  local check = readInteger(process)
  if check == pid then
    print("Process is still the same and available.")
  else
    print("Process has changed or is no longer available.")
  end
else
  print("No process is currently open.")
end

See also

Lua
Script Engine

Related Functions

createProcess
openProcess
onOpenProcess
getForegroundProcess
getOpenedProcessID
getProcessIDFromProcessName
openFileAsProcess
saveOpenedFile
setPointerSize
setAssemblerMode
getProcesslist
getWindowlist
pause
unpause
targetIs64Bit
enumModules
closeRemoteHandle