Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to display the name of the controls on focus?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Wed Mar 01, 2023 1:13 pm    Post subject: How to display the name of the controls on focus? Reply with quote

How to display the name of the controls on focus? Example: the trainer has 1000 controls, Edit boxes, Checkboxes, Buttons, etc. How to display name of the control when the control is clicked or focused?
Also, how to display Label, Progressbar, Panel, GroupBox name?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed Mar 01, 2023 7:42 pm    Post subject: This post has 2 review(s) Reply with quote

I hope you gave the name for all components on your form already.
If yes the look at example script below, if no I don't think you can get the name of the components with an event.

Code:
if f then f.destroy() end
f = createForm()
b1 = createButton(f)
b1.Name = 'b1'  ----- The name of component must be defined
e1 = createEdit(f)
e1.Top = 30
e1.Name = 'e1'  ----- The name of component must be defined

function getCtlName()
 for i = 0, f.ComponentCount - 1 do
  local compClassName = f.Component[i].ClassName
  local compName = f.Component[i].Name
  print(compName..' is a '..compClassName)
 end
end

f.Show()
getCtlName()


You can modify the script according to your needs.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Thu Mar 02, 2023 8:25 am    Post subject: Reply with quote

Corroder wrote:
I hope you gave the name for all components on your form already.

Yes, the components are created in the form designer.

Corroder wrote:
If yes the look at example script below.

This is almost exactly what I need. But, I need if the component is in focus, then display its name via print().
This code below works, but is there a way to display the name without the timer?
Code:
function getCtlName()
 for i = 0, UDF1.ControlCount - 1 do
  if UDF1.Control[i].focused() then
  local compName = UDF1.Component[i].Name
  print(compName)
 end
 end
end

function CETimer1Timer(sender)
getCtlName()
end
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Mar 02, 2023 8:33 am    Post subject: Reply with quote

WinControl descendants have an OnEnter and OnExit property
OnEnter is called when they gain control, OnExit when the focus is lost

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Mar 02, 2023 8:43 am    Post subject: This post has 1 review(s) Reply with quote

e.g:
Code:

function setOnEnter(c, f)
  c.OnEnter=f
  if c.ControlCount then
    for i = 0, c.ControlCount - 1 do
      setOnEnter(c.Control[i], f)
    end
  end
end

setOnEnter(UDF1, function(s)
  print(s.Name.." has focus")
end)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Thu Mar 02, 2023 10:21 am    Post subject: Reply with quote

Dark Byte wrote:
e.g:
Code:
function setOnEnter(c, f)

Thanks, this helped.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites