Lua:getWindowClassName
Jump to navigation
Jump to search
Returns the class name of the specified window.
Contents
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| windowhandle | Integer | The handle of the window to query. |
Returns[edit]
String — The class name of the specified window.
Examples[edit]
Get the class name of the main form[edit]
1 local form = getMainForm()
2 local windowHandle = form.Handle
3
4 local className = getWindowClassName(windowHandle)
5
6 print(className)
Get the class name of a created form[edit]
1 local form = createForm(false)
2 form.Caption = "Class Name Test"
3
4 local className = getWindowClassName(form.Handle)
5
6 print("Window class name: " .. tostring(className))
7
8 form.destroy()
Use with the foreground window[edit]
1 local windowHandle = getForegroundWindow()
2
3 if windowHandle ~= nil and windowHandle ~= 0 then
4 local className = getWindowClassName(windowHandle)
5
6 print("Foreground window class: " .. tostring(className))
7 end
Compare a window class name[edit]
1 local windowHandle = getForegroundWindow()
2
3 if windowHandle ~= nil and windowHandle ~= 0 then
4 local className = getWindowClassName(windowHandle)
5
6 if className == "TCEForm" then
7 print("The foreground window is a Cheat Engine form")
8 end
9 end
Get class name and process ID[edit]
1 local windowHandle = getForegroundWindow()
2
3 if windowHandle ~= nil and windowHandle ~= 0 then
4 local className = getWindowClassName(windowHandle)
5 local processID = getWindowProcessID(windowHandle)
6
7 print("Class: " .. tostring(className))
8 print("PID: " .. tostring(processID))
9 end
Guard against an invalid window handle[edit]
1 local windowHandle = 0
2
3 if windowHandle ~= nil and windowHandle ~= 0 then
4 local className = getWindowClassName(windowHandle)
5
6 print(className)
7 else
8 print("Invalid window handle")
9 end