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 


Replace Edit box with combobox in the Find/Replace windows?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Wed May 10, 2023 9:36 am    Post subject: Reply with quote

Razi wrote:
I have made these functions in CE, but not finished yet. (Need to know how to properly Move combobox items) But, this requires to edit 2 lazarus files: finddialog.inc, replacedialog.inc and compiling CE. Just need to add a few lines of code to these files. This can be done for any version of CE.


Code:

if f then f.destroy(); f = nil end

f = createForm(getMainForm())
f.Name = 'frmMain'
f.Caption = 'Main Form'
f.Width = 300
f.Height = 110
f.Position = 'poDesktopCenter'

c1 = createComboBox(f)
c1.Name = 'cmbOne'
c1.Text = ''
c1.Height = 32
c1.Width = f.Width - 25
c1.Top = 10
c1.Left = 15
-- Sadly, there is no 'OnCreate' event so have to use this hacky workaround
c1.OnEnter = function()
                local sl = createStringList()
                for i = 0, 10 do
                  sl.Add('Item ' .. tostring(i))
                end
                c1.Items = sl
                c1.Text = c1.Items[0]
                sl.destroy()
                sl = nil
              end
-- Set the focus of the component so the function can trigger
c1.setFocus()

c2 = createComboBox(f)
c2.Name = 'cmbTwo'
c2.Text = ''
c2.Height = 32
c2.Width = f.Width - 25
c2.Top = c1.Top + c2.Height + 10
c2.Left = 15

b1 = createButton(f)
b1.Name = 'btnCopy'
b1.Caption = 'Copy List'
b1.Width = 70
b1.Height = 30
b1.Top = f.Height - (b1.Height + 10)
b1.Left = f.Width - (b1.Width + 10)
b1.OnClick = function()
              local sl = createStringList()
              for i = 0, c1.Items.Count - 1 do
                  sl.Add(c1.Items[i])
              end
              c2.Items = sl
              c2.Text = c2.Items[0]
              sl.destroy()
              sl = nil
             end


Not the best, but it serves its purpose.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed May 10, 2023 8:17 pm    Post subject: Reply with quote

AylinCE wrote:


I am usually using codeblock to write long script Very Happy Very Happy
or other script editor which have 'run script menu' or compiler.
Write script on script editor which have best script editing tools then copy to CE Lua Script Table to test it.

Also consider to use CE synEdit or scite


However this is my old script to make an app call 'Text Manager".
Feel free to add utility such as 'highlighter, text replace, etc"

Code:
f=createForm()
f.setSize(550,550)
f.Position='poScreenCenter'
f.BorderStyle='bsSingle'
f.Color='7897995'
f.Caption='CRDR - CE Text Manager'
load_dialog = createOpenDialog(f)
save_dialog = createSaveDialog(f)

textbox=createEdit(f)
textbox.setPosition(5,5)
textbox.Autosize=false
textbox.setSize(280,28)
textbox.Font.Size=10
textbox.Color='13495295'
textbox.Text=""

searchButton=createButton(f)
searchButton.setPosition(textbox.Left+textbox.Width+10,5)
searchButton.setSize(80,27)
searchButton.Caption='Search Text'

lineButton=createButton(f)
lineButton.setPosition(searchButton.Left+searchButton.Width+5,5)
lineButton.setSize(80,27)
lineButton.Caption='Get Line'

openButton=createButton(f)
openButton.setPosition(lineButton.Left+lineButton.Width+5,5)
openButton.setSize(80,27)
openButton.Caption='Open File'

memo1=createMemo(f)
memo1.setPosition(5,textbox.Top+textbox.Height+10)
memo1.setSize(540,220)
memo1.BorderStyle='bsSingle'
memo1.HideSelection=false
memo1.WordWrap=false
memo1.ScrollBars='ssAutoBoth'
memo1.Color='13495295'
memo1.Font.Size = 10

memo2=createMemo(f)
memo2.setPosition(5,memo1.Top+memo1.Height+10)
memo2.setSize(540,220)
memo2.BorderStyle='bsSingle'
memo2.HideSelection=false
memo2.WordWrap=false
memo2.ScrollBars='ssAutoBoth'
memo2.Color='13495295'
memo2.Font.Size = 10

infoButton=createButton(f)
infoButton.setPosition(5,memo2.Top+memo2.Height+10)
infoButton.setSize(100,27)
infoButton.Caption='Get Info'

glosButton=createButton(f)
glosButton.setPosition(110,memo2.Top+memo2.Height+10)
glosButton.setSize(100,27)
glosButton.Caption='Glossary'

resetButton=createButton(f)
resetButton.setPosition(215,memo2.Top+memo2.Height+10)
resetButton.setSize(100,27)
resetButton.Caption='Reset'

saveButton=createButton(f)
saveButton.setPosition(445,memo2.Top+memo2.Height+10)
saveButton.setSize(100,27)
saveButton.Caption='Save Changes'

--------------------------------------------------------------------------------
local texture = [[
This is a dummy text for test all functions on this tool.
---------------------------------------------------------
cheat engine is a tool use to hack an app.
people mostly used cheat engine for hacking a game.
cheat engine is possible to manage memory such as
editing (reading and writing).
cheat engine made by Dark Byte a.k.a Eric henen.
cheat engine or CE, is an open-source
memory scanner/hex editor/debugger.
The first version of cheat engine has release at
June 28 2000 version 1.3 source code.
---------------------------------------------------------
]]

function init()
 memo1.Clear()
 memo1.Lines.Text = texture
 if memo1.Lines.Text == "" then
 infoButton.Enabled = false
 saveButton.Enabled = false
 else
 infoButton.Enabled = true
 saveButton.Enabled = true
 end
end

function charCount()
 cnt = memo1.Lines.Count-1
 s = memo1.Lines.Text
 c = string.len(s)
 _,n = s:gsub("%S+","")
 sumL = s:gsub("%s+", "")
 sumL = string.gsub(s, "%s+", "")
 str=string.len(sumL)
 whitespace = c - str
 info1 = 'Total Characters :   '..c..'   (including whitespace : '..whitespace..' )'
 info2 = 'Total Words :   '..n
 info3 = 'Total Lines :   '..cnt..'   (starting from line 0)'
 memo2.Clear()
 memo2.Lines.Add(info1)
 memo2.Lines.Add(info2)
 memo2.Lines.Add(info3)
end
infoButton.OnClick=charCount

function glsry()
 memo2.Clear()
 local sl = createStringList()
 local content = memo1.Lines.Text
 local wrd
 local words = {}
 local lines = {}
 local line_count = -1
 for l in content:gmatch("[^\n]+") do
 line_count = line_count + 1
 for w in l:gmatch("[^%s%p]+") do
 w = w:lower()
 words[w] = words[w] and words[w] + 1 or 1
 lines[w] = lines[w] or {}
 if lines[w][#lines[w]] ~= line_count then
 lines[w][#lines[w] + 1] = line_count
 end
 end
 end
 for w, count in pairs(words) do
 local the_lines = ""
 for _,line in ipairs(lines[w]) do
 the_lines = the_lines .. line .. ' / '
 end
 if count>1 then wrd = "words" else wrd = "word" end
 --print(w .." = " .. count .. " words , lines " .. the_lines)
 --memo2.Lines.Add(w .." = " .. count .. " ".. wrd .. "     [ lines : /  " .. the_lines .." ]")
 sl.Add(w .." = " .. count .. " ".. wrd .. "     [ lines : /  " .. the_lines .." ]")
 end
 sl.sorted = true
 for i=0, sl.Count-1 do
 memo2.Lines.Add(sl[i])
 end
 sl.destroy()
end
glosButton.OnClick=glsry

function getline()
 local m = textbox.Text
 local counter = memo1.Lines.Count-1
 if tonumber(m) ~= nil then
 m = tonumber(m)
 if m > counter then
 showMessage('Line number out of range. Max. Lines = '..counter)
 return
 end
 --memo2.Clear()
 memo2.Lines.Add('Line '..m..' : '..memo1.Lines[m])
 else
 showMessage('Please input line number..')
 return
 end
end
lineButton.OnClick=getline

function search(code,term)
 --memo2.Clear()
 code = memo1.Lines.Text
 term = textbox.Text
 if term == "" then
 showMessage("Please input words/characters to be search..")
 return nil
 end
 local n=0
 code="\n"..code
 code=code:gsub("\n", function () n=n+1 return "\n@"..n..":" end)
 memo2.Lines.Add('Search result for ['..term..'] found at :')
 memo2.Lines.Add('-------------------------------------------------------------')
 for a,b in code:gmatch("@(%d+):([^\n]-"..term.."[^\n]-)\n") do
 -- print('Line '..a..' : '..b)
 a = math.floor(a - 1)
 memo2.Lines.Add('Line '..a..' : '..b)
 end
 memo2.Lines.Add('=============================================================')
end
searchButton.OnClick = search

function reseter()
 memo2.Clear()
 textbox.Text = ""
end
resetButton.OnClick = reseter

local open = io.open
local function read_file(path)
 local file = open(path, "rb")
 if not file then
 showMessage("Error - can't read file content!")
 return nil
 end
 local content = file:read "*a"
 file:close()
 return content
end

function loadtext()
 load_dialog.InitalDir = os.getenv('%USERPROFILE%')
 load_dialog.Filter = 'Text files|*.TXT;*.txt|All files (*.*)|*'
 load_dialog.execute()
 local file = load_dialog.FileName
 local fileContent = read_file(file)
 memo1.Clear()
 memo1.Lines.Text = fileContent
end
openButton.OnClick = loadtext

function savechange()
 --local defaultpath = TrainerOrigin or getMainForm().SaveDialog1.InitialDir
 save_dialog.InitalDir = os.getenv('%USERPROFILE%')
 save_dialog.Filter = 'Text files|*.TXT;*.txt|All files (*.*)|*'
 save_dialog.execute()
 local file = save_dialog.FileName
 local fname = file
 contents = memo1.Lines.Text
 local file,err = io.open(file,'w')
 if file then
  file:write(contents)
  file:close()
  showMessage('Changed data has been saved on '..fname)
 else
  showMessage("error:", err)
 end
end
saveButton.OnClick = savechange

function closer()
 closeCE()
 return caFree
end
f.onClose = closer

--------------------------------------------------------------------------------
f.show()
init()

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Thu May 11, 2023 10:28 am    Post subject: Reply with quote

Corroder wrote:
......


Of course, I remember that. And I had asked that question
You completed this project to help.

But it has nothing to do with the current topic! Very Happy Twisted Evil Twisted Evil
Lua script testing required. Arrow Question

_________________
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
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu May 11, 2023 6:14 pm    Post subject: Reply with quote

Of course that not relative to current topic. If you see not whole script, there are some function on the script for example to find text. That's it why I show my script, then depending on the user skill to develop the example according user needs.

The topic: "Is it possible to replace Edit box with combobox in the Find and Replace windows in the CE Cheat Table Lua script and Lua Engine? "


So, that mean to change CE interface properties, specially for CE Cheat Tabe Lua Engine. The answer is yes that is possible.

Find or ask DB where is the pas file for CE Cheat Table Lua Engine and child script for that from CE source code and then do some modify according the needs, recompile and done. Of course you need have skill for Lazarus environments programming. Good luck!

_________________
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: Fri May 12, 2023 7:35 am    Post subject: Reply with quote

Corroder wrote:
do some modify according the needs, recompile and done. Of course you need have skill for Lazarus environments programming. Good luck!

Already done 2 or 3 days ago, screenshots are here
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri May 12, 2023 6:04 pm    Post subject: Reply with quote

Razi wrote:
Corroder wrote:
do some modify according the needs, recompile and done. Of course you need have skill for Lazarus environments programming. Good luck!

Already done 2 or 3 days ago, screenshots are here


Yes I saw it

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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
Goto page Previous  1, 2
Page 2 of 2

 
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