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 


read/write with several edit boxes

 
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: 205

PostPosted: Sat Dec 14, 2019 7:46 am    Post subject: read/write with several edit boxes Reply with quote

How to read/write with edit boxes in the following example? Maybe some piece of code can be improved, what do you advise?
Code:
baseaddr = 0x400000

function UDF1_CEListBox1Click(sender)
  for x = 0, 2 do
  UDF1_CEEdit ..17+x.. .Text = string.format('%04X', readSmallInteger(baseaddr+0x5BC6CA + x*2 + UDF1_CEListBox1.ItemIndex * 8))
  end
end


for x = 0, 2 do
function UDF1_CEEdit ..17+x.. KeyPress(sender, key)
      local a = tonumber(UDF1_CEEdit..17+x.. .Text, 16)
      if (a~=nil) and isKeyPressed(VK_RETURN) then
        writeSmallInteger(baseaddr+0x5BC6CA + x*2 + UDF1_CEListBox1.ItemIndex * 8, a)
      end
  return key
end
end
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Dec 14, 2019 8:45 am    Post subject: Reply with quote

There are many methods to access form controls by name (e.g. CEEdit1):
Code:
control_1_1 = UDF1.CEEdit1
control_1_2 = UDF1_CEEdit1
control_1_3 = UDF1["CEEdit1"]

return control_1_1 == control_1_2, control_1_2 == control_1_3

1:true
2:true

control_1_1, control_1_2 and control_1_3 are equal.
inside methods, use "sender".




EDIT:
Code:
baseaddr = 0x400000

local EditControls = {}
for x = 0,2 do
  EditControls[x] = UDF1["CEEdit"..(17+x)]
end

local function ListBoxClick(sender)
  local itemindex = sender.ItemIndex
  if itemindex~=-1 then
    for x = 0, 2 do
      EditControls[x].Text = string.format('%04X', readSmallInteger(baseaddr+0x5BC6CA + x*2 + itemindex * 8))
    end
  end
end

local function onkeypressex(sender, key, x)
  local a = tonumber(sender.Text, 16)
  local itemindex = UDF1.CEListBox1.ItemIndex
  if (a~=nil) and key=="\r" and itemindex~=-1 then
    writeSmallInteger(baseaddr+0x5BC6CA + x*2 + itemindex * 8, a)
  end
  return key
end

UDF1.CEListBox1.OnClick = ListBoxClick

for x = 0, 2 do
  EditControls[x].OnKeyPress = function(sender, key) return onkeypressex(sender, key, x) end
end



_________________
Back to top
View user's profile Send private message MSN Messenger
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 205

PostPosted: Sat Dec 14, 2019 2:20 pm    Post subject: Reply with quote

Thanks for the tips.
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