Difference between revisions of "Lua:getOpenedProcessID"

From Cheat Engine
Jump to navigation Jump to search
(Created page with ''''function''' getOpenedProcessID() Returns the process id of the process Cheat Engine has currently open. Returns the value 0 if no process is open ===Function Parameters=== …')
 
m
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
'''function''' getOpenedProcessID()
+
[[Category:Lua]]
 +
'''function''' getOpenedProcessID() ''':''' Integer
  
Returns the process id of the process Cheat Engine has currently open. Returns the value 0 if no process is open
+
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===
+
{{LuaFunctionParametersNone}}
<none>
 
  
== See also ==
+
===Returns===
* [[Lua]]
+
Integer — The process ID of the currently opened process, or 0 if none.
 +
 
 +
===Examples===
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
{{LuaSeeAlso}}
 +
 
 +
=== Related Functions ===
 +
* [[Lua:openProcess|openProcess]]
 +
* [[Lua:getProcesslist|getProcesslist]]
 +
* [[Lua:getProcessIDFromProcessName|getProcessIDFromProcessName]]
 +
* [[Lua:createProcess|createProcess]]
 +
* [[Lua:openFileAsProcess|openFileAsProcess]]

Latest revision as of 15:49, 11 July 2025

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[edit]

<none>

Returns[edit]

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

Examples[edit]

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[edit]

Related Functions[edit]