Difference between revisions of "Lua:getMainForm"
Jump to navigation
Jump to search
m (Reverted edits by This content is not available (Talk) to last revision by TheyCallMeTim13) |
(Major overhaul of the post.) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' getMainForm() ''':''' | + | {{CodeBox|'''function''' getMainForm() ''':''' Form}} |
| − | Returns the main | + | Returns the main Cheat Engine form object. |
| − | + | The returned object can be accessed using [[Lua:Class:Form|Form]] class properties and methods, as well as the properties and methods inherited from its parent classes. | |
| − | == Examples == | + | ===Function Parameters=== |
| − | + | This function has no parameters. | |
| − | + | ||
| + | ===Returns=== | ||
| + | [[Lua:Class:Form|Form]] — The main Cheat Engine form object. | ||
| + | |||
| + | ===Examples=== | ||
| + | |||
| + | ====Get the main form==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local mainForm = getMainForm() | ||
| + | |||
| + | print(mainForm.Caption) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Change the main form caption==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local mainForm = getMainForm() | ||
| + | |||
| + | mainForm.Caption = "Cheat Engine - Custom Caption" | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Read the main form size==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local mainForm = getMainForm() | ||
| + | |||
| + | print("Width : " .. tostring(mainForm.Width)) | ||
| + | print("Height: " .. tostring(mainForm.Height)) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Move the main form==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local mainForm = getMainForm() | ||
| + | |||
| + | mainForm.Left = 100 | ||
| + | mainForm.Top = 100 | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Center the main form on screen==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local mainForm = getMainForm() | ||
| + | |||
| + | mainForm.Position = "poScreenCenter" | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Access the main menu==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local mainForm = getMainForm() | ||
| + | |||
| + | print(mainForm.Menu) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Hide and show the main form==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local mainForm = getMainForm() | ||
| + | |||
| + | mainForm.hide() | ||
| + | sleep(1000) | ||
| + | mainForm.show() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Create a button on the main form==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local mainForm = getMainForm() | ||
| + | local button = createButton(mainForm) | ||
| + | |||
| + | button.Caption = "Click Me" | ||
| + | button.Left = 10 | ||
| + | button.Top = 10 | ||
| + | button.Width = 100 | ||
| + | button.OnClick = function() | ||
| + | showMessage("Button clicked") | ||
| + | end | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Use inherited Control properties==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | local mainForm = getMainForm() | ||
| + | |||
| + | print("Visible: " .. tostring(mainForm.Visible)) | ||
| + | print("Enabled: " .. tostring(mainForm.Enabled)) | ||
| + | </syntaxhighlight> | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | + | {{Forms}} | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 19:55, 25 June 2026
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.
Contents
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"
[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))