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 


Cheat Engine Forum Index
PostGo back to topic
Corroder
Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed Jun 12, 2019 10:53 pm    Post subject: CRDR - CE Text Manager / Text Finder

In relation to these topics:

https://forum.cheatengine.org/viewtopic.php?t=610292
https://forum.cheatengine.org/viewtopic.php?t=610277

This is a text finder/text manager I have provided.

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()


Copy those code to your CE Lua Table Script and save as a CT file. Or CETRAINER/EXE file (if you are very very super care your code will be stolen).

Demo Video:

https://youtu.be/u9XuSfIYRIc


Need to do:
- Add a function to read/open a text file from a URL
- Handle Unicode/UTF-16 texts or Non-Latin Windows Codepage
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Post reviews:   Approve 1
Author Review
AylinCE
Review: Approve
Post reference:
ReviewPosted: Thu Jun 13, 2019 6:16 am

Thanks nice work!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display:  
Cheat Engine Forum Index


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites