Lua:getWindowlist

From Cheat Engine
Revision as of 19:14, 25 June 2026 by Leunsel (talk | contribs) (Major overhaul of the post.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<> Lua API Reference

function getWindowlist() : table

Returns a table containing the currently visible window list.

The returned table is grouped by process ID. Each process ID maps to another table where the keys are window IDs and the values are window captions.

Function Parameters[edit]

This function has no parameters.

Returns[edit]

Table — A table containing process IDs, window IDs, and window captions.

Return Table Structure[edit]

Level Type Description
PID Integer The process ID that owns one or more windows.
Window ID Integer The index or ID of a window entry belonging to that process.
Caption String The caption text of the window.

Description[edit]

getWindowlist returns information about open windows grouped by their owning process ID.

The general structure is:

windowList[processID][windowID] = windowCaption

A single process can have multiple window entries. Some entries may have the same caption, and some windows may have system-generated captions such as IME or framework-related window names.

Examples[edit]

Get the window list[edit]

1 local windowList = getWindowlist()
2 
3 print(windowList)

Print all window captions[edit]

1 local windowList = getWindowlist()
2 
3 for pid, windows in pairs(windowList) do
4   for id, caption in pairs(windows) do
5     print("PID: " .. tostring(pid) .. ", ID: " .. tostring(id) .. ", Caption: " .. caption)
6   end
7 end

Find windows by caption text[edit]

 1 local windowList = getWindowlist()
 2 local searchText = "Cheat Engine"
 3 
 4 for pid, windows in pairs(windowList) do
 5   for id, caption in pairs(windows) do
 6     if caption:find(searchText, 1, true) ~= nil then
 7       print("Found: PID=" .. tostring(pid) .. ", ID=" .. tostring(id) .. ", Caption=" .. caption)
 8     end
 9   end
10 end

Collect all windows for a specific process ID[edit]

1 local windowList = getWindowlist()
2 local targetPID = getOpenedProcessID()
3 local windows = windowList[targetPID]
4 
5 if windows ~= nil then
6   for id, caption in pairs(windows) do
7     print("Window " .. tostring(id) .. ": " .. caption)
8   end
9 end

Example return data[edit]

 1 local windowList = getWindowlist()
 2 
 3 -- Example shape:
 4 -- windowList = {
 5 --   [21112] = {
 6 --     [1] = "Cheat Engine 7.4",
 7 --     [2] = "Cheat Engine 7.4",
 8 --     [3] = "Cheat Engine settings",
 9 --     [4] = "Default IME",
10 --     [5] = "Lua Engine",
11 --     [6] = "MSCTFIME UI"
12 --   }
13 -- }

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Process Open / Creation

Process Lists / Modules

Process Control / Target State