Lua:getMainForm

From Cheat Engine
Jump to navigation Jump to search

<> Lua API Reference

function getMainForm() : Form

Returns the main Cheat Engine form object.

The returned object can be accessed using Form class properties and methods, as well as the properties and methods inherited from its parent classes.

Function Parameters[edit]

This function has no parameters.

Returns[edit]

Form — The main Cheat Engine form object.

Examples[edit]

Get the main form[edit]

1 local mainForm = getMainForm()
2 
3 print(mainForm.Caption)

Change the main form caption[edit]

1 local mainForm = getMainForm()
2 
3 mainForm.Caption = "Cheat Engine - Custom Caption"

Read the main form size[edit]

1 local mainForm = getMainForm()
2 
3 print("Width : " .. tostring(mainForm.Width))
4 print("Height: " .. tostring(mainForm.Height))

Move the main form[edit]

1 local mainForm = getMainForm()
2 
3 mainForm.Left = 100
4 mainForm.Top = 100

Center the main form on screen[edit]

1 local mainForm = getMainForm()
2 
3 mainForm.Position = "poScreenCenter"

Access the main menu[edit]

1 local mainForm = getMainForm()
2 
3 print(mainForm.Menu)

Hide and show the main form[edit]

1 local mainForm = getMainForm()
2 
3 mainForm.hide()
4 sleep(1000)
5 mainForm.show()

Create a button on the main form[edit]

 1 local mainForm = getMainForm()
 2 local button = createButton(mainForm)
 3 
 4 button.Caption = "Click Me"
 5 button.Left = 10
 6 button.Top = 10
 7 button.Width = 100
 8 button.OnClick = function()
 9   showMessage("Button clicked")
10 end

Use inherited Control properties[edit]

1 local mainForm = getMainForm()
2 
3 print("Visible: " .. tostring(mainForm.Visible))
4 print("Enabled: " .. tostring(mainForm.Enabled))

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Form Related Classes