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 


Can Lua achieve the effect of adding pointer gui on ce?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 72

PostPosted: Wed Jul 07, 2021 10:39 pm    Post subject: Can Lua achieve the effect of adding pointer gui on ce? Reply with quote

Can Lua achieve the effect of adding pointer gui on ce?
such as
--
CB = createCheckBox(f)
??
add edit
add edit
..
..
Button add offset ..Button remove offset
---

Used to add multiple addresses with a common base address,
Add a few edits,Variable createEdit。Not need to change the code every time.
Code:

f = createForm(true)
f.Position=poDesktopCenter
f.Width=550
f.Height=300
f.Caption = 'Add addresses in Batches'


L1 = createLabel(f)
L1.Left = 26
L1.Top = 11
L1.Font.Size = 12
L1.Caption = 'Add description here↓'

local m1=createMemo(f)
m1.Height=180
m1.Left=10
m1.Top=50
m1.Width=240
m1.WordWrap=false
m1.ScrollBars="ssAutoBoth"

L2 = createLabel(f)
L2.Left = 280
L2.Top = 11
L2.Font.Size = 12
L2.Caption = 'Add the address corresponding to \n the description↓'


local m2=createMemo(f)
m2.Height=180
m2.Left=275
m2.Top=50
m2.Width=240
m2.WordWrap=false
m2.ScrollBars="ssAutoBoth"

local b=createButton(f)
b.Left=230
b.Top=260
b.caption="Add"

b.OnClick=function()
local sr1 = m1.getLines()
local sr2 = m2.getLines()
local jn = {}
for n = 0, sr2.Count - 1 do
  jn[n] = tonumber(sr2.String[n], 16)
  local al=getAddressList()
  local shc = al.createMemoryRecord()
  local py = jn[n]
  shc.setAddress("3432C0")--Change here to target
  shc.setOffsetCount(2)
  shc.setOffset(0, py)
  shc.setOffset(1, 0x5F1F4)--Change here to target
  shc.Type = vtCustom
  shc.CustomTypeName = 'abc'
  shc.description=sr1.String[n]
end
end
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Thu Jul 08, 2021 9:45 am    Post subject: Reply with quote

I didn't quite understand what you wanted, I just simulated the table generating and interacting with the gui.
If you want to explain a little more, I'm here.

Code:
if f then f.Destroy() f=nil end
f = createForm(true)
f.Position=poDesktopCenter
f.Width=700
f.Height=300
f.Caption = 'Add addresses in Batches'

L1 = createLabel(f)
L1.Left = 26
L1.Top = 11
L1.Font.Size = 12
L1.Caption = 'Add description here↓'

local m1=createMemo(f)
m1.Height=180
m1.Left=10
m1.Top=50
m1.Width=240
m1.WordWrap=false
m1.ScrollBars="ssAutoBoth"

L2 = createLabel(f)
L2.Left = 280
L2.Top = 11
L2.Font.Size = 12
L2.Caption = 'Add the address corresponding to \n the description↓'

local m2=createMemo(f)
m2.Height=180
m2.Left=260
m2.Top=50
m2.Width=240
m2.WordWrap=false
m2.ScrollBars="ssAutoBoth"

P2 = createListBox(f)
P2.Height=180
P2.Left = 510
P2.Top = 50
P2.Width=180
P2.Color=14671775

local b=createButton(f)
b.Left=230
b.Top=260
b.caption="Add"

local b1=createButton(f)
b1.Left=535
b1.Top=240
b1.caption="Load Address List"
b1.Width=140

local top1 = -15
local chk11={ }

function onHack(sender)
addresslist=getAddressList()
local name=sender.caption
--print(name)
  if sender.checked==true then
   CheatEntry=addresslist_getMemoryRecordByDescription(addresslist,name)
   memoryrecord_freeze(CheatEntry)
   else
 CheatEntry=addresslist_getMemoryRecordByDescription(addresslist,name)
   memoryrecord_unfreeze(CheatEntry)
  end
end

function addChkBox(chName)
--print("chName: "..chName)
top1=tonumber(top1) + 20
chk11.chName=createCheckBox(P2)
chk11.chName.caption=chName
chk11.chName.Left=5
chk11.chName.Top=top1
chk11.chName.OnChange=onHack
end

b.OnClick=function()
local sr1 = m1.getLines()
local sr2 = m2.getLines()
local jn = {}
for n = 0, sr1.Count - 1 do
  jn[n] = tonumber(sr2.String[n], 16)
  local al=getAddressList()
  local shc = al.createMemoryRecord()
  local py = jn[n]
  --shc.setAddress("3432C0")--Change here to target
  --shc.setOffsetCount(2)
  --shc.setOffset(0, py)
  --shc.setOffset(1, 0x5F1F4)--Change here to target
  name11=sr2.String[n]
  if name11=="" then
  shc.Type = 11 end --vtCustom
  --shc.CustomTypeName = 'abc'
  shc.description=sr1.String[n]
  addChkBox(shc.description)
end
end

b1.OnClick=function()
P2.Clear()
  al=getAddressList()
  for i=0, al.Count-1 do
  values=(al[i].Description)

  addChkBox(values)
  end
end
Back to top
View user's profile Send private message
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 72

PostPosted: Thu Jul 08, 2021 9:34 pm    Post subject: Reply with quote

Thank you for your answer

to add this adress

[[[abc.exe]+123]+45]+4
[[[abc.exe]+123]+45]+8
[[[abc.exe]+123]+45]+c
[[[abc.exe]+123]+45]+10
....


They have a common base address and pointer

Can be expressed by code
Code:

 shc.setAddress("abc.exe")--Change here to target
  shc.setOffsetCount(3)
  shc.setOffset(0, py)
  shc.setOffset(1, 0x123)--Change here to target
  shc.setOffset(2, 0x45)--Change here to target


4,8,c,10 can Put in Memo

Can put Same base address abc.exe and 123 in a place like ce ,ce adding pointer gui can use lua achieve?
like this↓



jizhi2.JPG
 Description:
 Filesize:  66.74 KB
 Viewed:  3564 Time(s)

jizhi2.JPG


Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Fri Jul 09, 2021 1:44 am    Post subject: Reply with quote

A slightly different approach. Additions can be made for other types other than pointers.

Code:
if f then f.Destroy() f=nil end
f = createForm(true)
f.Position=poDesktopCenter
f.Width=450
f.Height=260
f.Caption = 'Add addresses in Batches'

L2 = createLabel(f)
L2.Left=30 L2.Top=11 L2.Font.Size=12
L2.Caption='Add the address corresponding to \n and Offset (or "" (No 0x)) ↓'

L3=createLabel(f)
L3.Left=10 L3.Top=56 L3.Font.Size=12 L3.Caption="Description: "

L4=createLabel(f)
L4.Left=10 L4.Top=80 L4.Font.Size=12 L4.Caption="Address....: "

L5=createLabel(f)
L5.Left=10 L5.Top=104 L5.Font.Size=12 L5.Caption="Offset(0)...: "

L6=createLabel(f)
L6.Left=10 L6.Top=128 L6.Font.Size=12 L6.Caption="Offset(1)...: "

L7=createLabel(f)
L7.Left=10 L7.Top=152 L7.Font.Size=12 L7.Caption="Offset(2)...: "

L8=createLabel(f)
L8.Left=10 L8.Top=176 L8.Font.Size=12 L8.Caption="Offset(3)...: "

L9=createLabel(f)
L9.Left=10 L9.Top=200 L9.Font.Size=12 L9.Caption="Offset(4)...: "

E1=createEdit(f) E1.AutoSize=false E1.Height=20
E1.Left=90 E1.Top=55 E1.Font.Size=12 E1.Width=160

E2=createEdit(f) E2.AutoSize=false E2.Height=20
E2.Left=90 E2.Top=79 E2.Font.Size=12 E2.Width=160

E3=createEdit(f) E3.AutoSize=false E3.Height=20
E3.Left=110 E3.Top=103 E3.Font.Size=12 E3.Width=140

E4=createEdit(f) E4.AutoSize=false E4.Height=20
E4.Left=110 E4.Top=127 E4.Font.Size=12 E4.Width=140

E5=createEdit(f) E5.AutoSize=false E5.Height=20
E5.Left=110 E5.Top=151 E5.Font.Size=12 E5.Width=140

E6=createEdit(f) E6.AutoSize=false E6.Height=20
E6.Left=110 E6.Top=175 E6.Font.Size=12 E6.Width=140

E7=createEdit(f) E7.AutoSize=false E7.Height=20
E7.Left=110 E7.Top=199 E7.Font.Size=12 E7.Width=140

P2 = createListBox(f)
P2.Height=165
P2.Left = 260
P2.Top = 55
P2.Width=180
P2.Color=14671775

local b=createButton(f)
b.Left=10
b.Top=225
b.caption="Add"
b.Width=80

local b1=createButton(f)
b1.Left=260
b1.Top=225
b1.caption="Load Address List"
b1.Width=125

local b2=createButton(f)
b2.Left=110
b2.Top=225
b2.caption="Clear Offsets"
b2.Width=140

local b3=createButton(f)
b3.Left=390
b3.Top=225
b3.caption="Clear"
b3.Width=50

local top1 = -15
local chk11={ }

function onHack(sender)
addresslist=getAddressList()
local name=sender.caption
--print(name)
  if sender.checked==true then
   CheatEntry=addresslist_getMemoryRecordByDescription(addresslist,name)
   memoryrecord_freeze(CheatEntry)
   else
 CheatEntry=addresslist_getMemoryRecordByDescription(addresslist,name)
   memoryrecord_unfreeze(CheatEntry)
  end
end

function addChkBox(chName)
--print("chName: "..chName)
top1=tonumber(top1) + 20
chk11.chName=createCheckBox(P2)
chk11.chName.caption=chName
chk11.chName.Left=5
chk11.chName.Top=top1
chk11.chName.OnChange=onHack
end

local OffCount=0

function CounOffs1()
OffCount=0
if E3.Text~="" then OffCount=1 end
if E4.Text~="" then OffCount=2 end
if E5.Text~="" then OffCount=3 end
if E6.Text~="" then OffCount=4 end
if E7.Text~="" then OffCount=5 end
return OffCount
end

b.OnClick=function()
  local al=getAddressList()
  local shc = al.createMemoryRecord()
  CounOffs1()
  if E2.Text~="" then
  shc.setAddress(E2.Text) end
  shc.setOffsetCount(tonumber(OffCount))
  if E3.Text~="" then
  shc.setOffset(0, "0x"..E3.Text) end
  if E4.Text~="" then
  shc.setOffset(1, "0x"..E4.Text) end
  if E5.Text~="" then
  shc.setOffset(2, "0x"..E5.Text) end
  if E6.Text~="" then
  shc.setOffset(3, "0x"..E6.Text) end
  if E7.Text~="" then
  shc.setOffset(4, "0x"..E7.Text) end
  shc.Type = vtCustom
  shc.description=E1.Text
  addChkBox(shc.description)
end

b1.OnClick=function()
P2.Clear()
  al=getAddressList()
  for i=0, al.Count-1 do
  values=(al[i].Description)

  addChkBox(values)
  end
end

b2.OnClick=function()
--E1.Text=""
E2.Text="" E3.Text="" E4.Text="" E5.Text="" E6.Text=""
end

b3.OnClick=function()
P2.Clear()
end



Ek1.PNG
 Description:
 Filesize:  63.6 KB
 Viewed:  3546 Time(s)

Ek1.PNG


Back to top
View user's profile Send private message
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 72

PostPosted: Mon Jul 12, 2021 12:45 am    Post subject: Reply with quote

so,as you say, Lua does not provide a function to change the form
another method ,But not for use,Because the text of Memo and Edit cannot be saved like the lua window.
Code:

f = createForm(true)
f.Position=poDesktopCenter
f.Width=750
f.Height=300
f.Caption = 'Add addresses in Batches'


L1 = createLabel(f)
L1.Left = 26
L1.Top = 11
L1.Font.Size = 12
L1.Caption = 'Add description here↓'

local m1=createMemo(f)
m1.Height=180
m1.Left=10
m1.Top=50
m1.Width=240
m1.WordWrap=false
m1.ScrollBars="ssAutoBoth"

L2 = createLabel(f)
L2.Left = 280
L2.Top = 11
L2.Font.Size = 12
L2.Caption = 'Last offset corresponding to \n the description↓'


local m2=createMemo(f)
m2.Height=180
m2.Left=275
m2.Top=50
m2.Width=240
m2.WordWrap=false
m2.ScrollBars="ssAutoBoth"


E=createEdit(f)
E.Left=560
E.Top=11
E.Width=160
E.TextHint='base adress'

L3 = createLabel(f)
L3.Left = 560
L3.Top = 50
L3.Font.Size = 12
L3.Caption = 'Same offset↓'

local m3=createMemo(f)
m3.Height=180
m3.Left=560
m3.Top=80
m3.Width=160
m3.WordWrap=false
m3.ScrollBars="ssAutoBoth"



local b=createButton(f)
b.Left=230
b.Top=260
b.caption="Add"

b.OnClick=function()
  local sr1 = m1.getLines()
  local sr2 = m2.getLines()
  local sr3 = m3.getLines()
  local jn = {}
for n = 0, sr2.Count - 1 do
  jn[n] = tonumber(sr2.String[n], 16)
  local al=getAddressList()
  local shc = al.createMemoryRecord()
  local py = jn[n]
  shc.setAddress(E.Text)
  shc.setOffsetCount(sr3.Count+1)
  shc.setOffset(0,py)
   for b = 0,sr3.Count-1 do
   local sm = {}
   sm[b] = tonumber(sr3.String[b], 16)
   shc.setOffset(b+1,sm[b])
   end
  shc.Type = vtCustom
  shc.CustomTypeName = 'abc'
  shc.description=sr1.String[n]
 end
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: Mon Jul 12, 2021 2:13 am    Post subject: Reply with quote

this code will change the form
Code:

function forEachAndFutureForm(classname, func)
  local i
  for i=0,getFormCount()-1 do
    local f
    f=getForm(i)
    if f.ClassName==classname then
      func(f)
    end
  end

  registerFormAddNotification(function(f)
    if classname==f.ClassName then
      f.registerFirstShowCallback(function()
        func(f)
      end)
    end
  end)
end

forEachAndFutureForm('TformAddressChange',function(f)
  local mylabel=createLabel(f)
  mylabel.caption='New label'
  mylabel.Top=f.LabelAddress.Top
  mylabel.Left=f.LabelAddress.Left+f.LabelAddress.Width+10
  mylabel.Font.Color=0xff0000

  local oldOK=f.btnOk.OnClick
  f.btnOk.OnClick=function(sender)
    if messageDialog('Are you sure this is the correct address?', mtWarning, mbYes,mbNo)==mrYes then
      oldOK(sendeR)
    end
  end
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
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 72

PostPosted: Mon Jul 12, 2021 7:04 am    Post subject: Reply with quote

Sorry for the wrong statement,but How to add an edit per click?

This is a wrong attempt
Code:

f = createForm(true)
f.Position=poDesktopCenter
f.Width=300
f.Height=300
f.Caption = 'Add addresses in Batches'

local m1=createMemo(f)
m1.Height=180
m1.Left=10
m1.Top=50
m1.Width=240
m1.WordWrap=false
m1.ScrollBars="ssAutoBoth"

local b=createButton(f)
b.Left=10
b.Top=260
b.caption="Add"

local jn = {}
local ec = 1
local bp = 240
b.OnClick=function()
 f.Height = f.Height + 60
 b.Top = b.Top + 60
 jn[ec]=createEdit(f)
----jn[ec].Left=560//worng
jn[ec].Left=10--fix
 jn[ec].Top= b.Top - 10
 jn[ec].Width=160
 ec =ec + 1
end


Last edited by etioplmld on Thu Dec 23, 2021 1:25 am; edited 2 times in total
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Mon Jul 12, 2021 9:01 am    Post subject: Reply with quote

It is possible to do this. But you can't give functions to get "OnClick" or "Text".
Because "local" will always be in the last generated "Edt..ec".
As a result; You must create these newly produced "Edits" in the function you will use.
Or let me offer you an alternative code.

Code:
f = createForm(true)
f.Position=poDesktopCenter
f.Width=300
f.Height=260
f.Caption = 'Add addresses in Batches'

local m1=createMemo(f)
m1.Height=180
m1.Left=10
m1.Top=40
m1.Width=240
m1.WordWrap=false
m1.ScrollBars="ssAutoBoth"

local b=createButton(f)
b.Left=10
b.Top=f.Height - 30
b.caption="Add"

local jn = { }
local ec = 0
local bp = 240
b.OnClick=function()
 f.Height = f.Height + 27
 ec =tonumber(ec) + 1
 name1="edt"..ec
 jn.name1=createEdit(f)
 jn.name1.Name=name1
 print(jn.name1.Name)
 jn.name1.AutoSize=false
 jn.name1.Height=22
 jn.name1.Left=10
 jn.name1.Width=160
b.Top=f.Height - 30
 jn.name1.Top= b.Top - 27
end


EDIT:
Added 5 "Edits". + 1 button (Clear) has been added.

Code:
f = createForm(true)
f.Position=poDesktopCenter
f.Width=300
f.Height=260
f.Caption = 'Add addresses in Batches'

local m1=createMemo(f)
m1.Height=180
m1.Left=10
m1.Top=40
m1.Width=240
m1.WordWrap=false
m1.ScrollBars="ssAutoBoth"

local b=createButton(f)
b.Left=10
b.Top=f.Height - 30
b.caption="Add"

local b1=createButton(f)
b1.Left=95
b1.Top=f.Height - 30
b1.caption="Clear"

local jn = { }

jn.edt1=createEdit(f)
jn.edt1.AutoSize=false jn.edt1.Height=22 jn.edt1.Left=10
jn.edt1.Width=160 jn.edt1.Top= - 60

jn.edt2=createEdit(f)
jn.edt2.AutoSize=false jn.edt2.Height=22 jn.edt2.Left=10
jn.edt2.Width=160 jn.edt2.Top= - 60

jn.edt3=createEdit(f)
jn.edt3.AutoSize=false jn.edt3.Height=22 jn.edt3.Left=10
jn.edt3.Width=160 jn.edt3.Top= - 60

jn.edt4=createEdit(f)
jn.edt4.AutoSize=false jn.edt4.Height=22 jn.edt4.Left=10
jn.edt4.Width=160 jn.edt4.Top= - 60

jn.edt5=createEdit(f)
jn.edt5.AutoSize=false jn.edt5.Height=22 jn.edt5.Left=10
jn.edt5.Width=160 jn.edt5.Top= - 60

local ec = 0
local ec1 = 0
local bp = 240
b.OnClick=function()
 if ec~=5 then
 f.Height = f.Height + 27
 ec =tonumber(ec) + 1
 ec1 =tonumber(ec1) + 1
 name1=jn["edt"..ec]
--name1=tostring(name1)
b.Top=f.Height - 30
b1.Top=f.Height - 30
 name1.Top= b.Top - 27
 end
end

b1.OnClick=function()
 if ec1~=0 then
 f.Height = f.Height - 27
 name1=jn["edt"..ec]
 ec =tonumber(ec) - 1
 ec1 =tonumber(ec1) - 1
--name1=tostring(name1)
b.Top=f.Height - 30
b1.Top=f.Height - 30
 name1.Top= - 60
 end
end
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Tue Jul 13, 2021 6:21 pm    Post subject: Reply with quote

Final. Look at it, add and edit things.

https://forum.cheatengine.org/viewtopic.php?p=5772163

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 72

PostPosted: Thu Dec 09, 2021 7:53 am    Post subject: Reply with quote

Code:

f = createForm(true)
f.Position=poDesktopCenter
f.Width=300
f.Height=115
f.Caption = 'Add addresses '

local b1=createButton(f)
b1.Left=180
b1.Top=10
b1.caption="add address"
b1.Width=100

local b2=createButton(f)
b2.Left=180
b2.Top=40
b2.caption="add offset"
b2.Width=100

local b3=createButton(f)
b3.Left=180
b3.Top=70
b3.caption="remove offset"
b3.Width=100

local eb=createEdit(f)
eb.Left=10
eb.Top=10
eb.Width=130
eb.TextHint='base address'

local eb1 =createEdit(f)
eb1.Left=10
eb1.Top=40
eb1.Width=130
eb1.Text= 1

bn = 1
local jn = {}
b2.OnClick=function()
 jn[bn] = string.format("ex%d", bn)
 jn[bn]=createEdit(f)
 jn[bn].Left=10
 jn[bn].Top= 70 + 25*bn
 jn[bn].TextHint=string.format("offset%d", bn)
bn = bn + 1
f.Height=f.Height + 25

end

b3.OnClick=function()
bn= bn -1
jn[bn].destroy()
jn[bn]=nil
f.Height=f.Height - 25
end

b1.OnClick=function()
if( bn == 1)
then
gn=tonumber(eb1.Text,16)
for n=1,gn do
local al = getAddressList()
local rec = al.createMemoryRecord()
fl=tonumber(eb.Text)+n*4
kl = tostring(fl)
rec.setAddress(kl)
end

elseif( bn == 2 )
then
gn=tonumber(eb1.Text)
for n = 0,gn-1 do
local al = getAddressList()
local rec = al.createMemoryRecord()
fofst = tonumber(jn[1].Text,16)+ n*4
rec.setAddress(eb.Text)
rec.setOffsetCount(1)
rec.setOffset(0,fofst)
end
elseif( bn > 2 )
then
gn=tonumber(eb1.Text)

for n = 0,gn-1 do
local al = getAddressList()
local rec = al.createMemoryRecord()
fofst = tonumber(jn[1].Text,16)+ n*4

rec.setAddress(eb.Text)
rec.setOffsetCount(bn-1)
rec.setOffset(0,fofst)
for p = 1 ,bn-2 do
s = tonumber(jn[p+1].Text,16)
rec.setOffset(p,s)
end
end

else
print("error")

end
end

----------------
After trying a lot of code, this is a result 。
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