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 


Running Process List With Filter And Show Memory Usage

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater
Reputation: 27

Joined: 10 Apr 2015
Posts: 983

PostPosted: Wed Jul 31, 2019 9:38 pm    Post subject: Running Process List With Filter And Show Memory Usage Reply with quote

This just an example to get all running process on CPU memory and have the ability to filtering the process by name and check how much memory consumed by the process.

Code:
f = createForm() f.setSize(400,400) f.Caption = "Sorted Process List" setProperty(f , "BiDiMode", "bdLeftToRight")
list = createListBox(f) x,y = f.getSize() list.setSize(x-10, y-40) list.setPosition(5,5)
button1 = createButton(f) button2 = createButton(f) button3 = createButton(f) button1.setSize(80, 25)
button2.setSize(80, 25) button3.setSize(80, 25) button1.Caption = "Get Process" button2.Caption = "Clear" button3.Caption = "Attach"
button1.setPosition(5,y-30) button2.setPosition(90,y-30) button3.setPosition(175,y-30)
l = createLabel(f) l.Caption = 'Filter' l.setPosition(265,y-25) edt = createEdit(f) edt.setPosition(300,371)
edt.setSize(90, 25) edt.Text = '' function getAllProcess()  taskpath = TrainerOrigin or getMainForm()  os.execute("tasklist /fo csv /nh > "..taskpath.."\\tasklist.txt")
local taskfile = io.open(taskpath.."\\tasklist.txt", "r")  list.clear()  for line in taskfile:lines() do  rst = string.gsub(line,'"', '')
fin = string.gsub(rst,',', ' - ')  list.Items.Add(fin)  end  list.sorted = true  taskfile:close()  os.remove(taskpath.."\\tasklist.txt") end
function filterprocess() local pro = edt.Text if pro == "" or pro == nil then return nil end taskpath = TrainerOrigin or getMainForm() os.execute("tasklist /fo csv /nh > "..taskpath.."\\tasklist.txt") local taskfile = io.open(taskpath.."\\tasklist.txt", "r")
list.clear() for line in taskfile:lines() do rst = string.gsub(line,'"', '') fin = string.gsub(rst,',', ' - ')  if string.match(fin, pro) then list.Items.Add(fin) end end list.sorted = true taskfile:close() os.remove(taskpath.."\\tasklist.txt") end
function kdown(sender, Key) if Key == VK_RETURN then filterprocess() end end function clearing() list.clear() end
function attaching() index = list.ItemIndex local item = list.Items[index] pro = item:match("(.+).exe") pro = pro..'.exe' openProcess(pro) end
button1.onClick = getAllProcess button2.onClick = clearing button3.onClick = attaching edt.onKeyDown = kdown


Just copy paste and execute the code above to your CE Lua script table.
By default, it will show you: Process name, PID, Session, Serve, and Memory Usage (in Kb)


To use :
- Click button 'Get Process' to get all the running process and display on the list table
- Click button ''Clear'' to clear process list table
- Select a process from the list table and click button 'Attach' to open the selected process
- Typing a process name on 'text box' ) eq.forefox.exe and press ENTER to filtering specific process

You are free to edit the code and make it better.

Enjoy...


EDIT:

This one more elegance.

Code:
f = createForm() f.setSize(300,300) f.Position = 'poScreenCenter' setProperty(f , "BiDiMode", "bdLeftToRight") f.Caption = 'CRDR - Process List'
list = createListBox(f) x,y = f.getSize() list.setSize(x-10, y-70) list.setPosition(5,5)
button1 = createButton(f) button2 = createButton(f) button3 = createButton(f)
button1.setSize(80, 25) button2.setSize(80, 25) button3.setSize(80, 25)
button1.Caption = "Get Process" button2.Caption = "Clear" button3.Caption = "Attach"
button1.setPosition(20,y-60) button2.setPosition(110,y-60) button3.setPosition(200,y-60)
l = createLabel(f) l.Caption = 'Filter' l.setPosition(20,y-25)
edt = createEdit(f) edt.setPosition(50,y-30) edt.setSize(228, 25) edt.Text = ''
function getprocesses()  local tasklist = io.popen"tasklist /fo csv /nh"  local plist = {}  local proc_item  list.clear()  for line in tasklist:lines() do    local exe, pid, mem = line:match'^"(.-)","(%d+)",.-"([^"]+)"$'    table.insert(plist, {pid = tonumber(pid), exe = exe, mem = tonumber((mem:gsub("%D", "")))})
 end  tasklist:close()  table.sort(plist, function(a, b) return a.mem > b.mem end)  for j = 1, math.min(120, #plist) do   proc_item = string.format(plist[j].pid..' - '..plist[j].exe..' - '..plist[j].mem..' Kb')   list.Items.Add(proc_item)  end end function filterprocess()  local pro = edt.Text
 if pro == "" or pro == nil then return nil end  local tasklist = io.popen"tasklist /fo csv /nh"  local plist = {}  local proc_item  list.clear()
 for line in tasklist:lines() do    local exe, pid, mem = line:match'^"(.-)","(%d+)",.-"([^"]+)"$'    table.insert(plist, {pid = tonumber(pid), exe = exe, mem = tonumber((mem:gsub("%D", "")))})  end  tasklist:close()  table.sort(plist, function(a, b) return a.mem > b.mem end)  for j = 1, math.min(120, #plist) do
  if plist[j].exe == pro then    proc_item = string.format(plist[j].pid..' - '..plist[j].exe..' - '..plist[j].mem..' Kb')    list.Items.Add(proc_item)   end  end end
function kdown(sender, Key)  if Key == VK_RETURN then filterprocess() end end  function clearing()  list.clear() end  function attaching()  local a = list.ItemIndex  local pro = list.Items[a]  local id, name, mem = pro:match("%s(.*)-%s(.*)-%s(.*)")  name = name:gsub("^%s*(.-)%s*$", "%1")  openProcess(name) end  button1.onClick = getprocesses button2.onClick = clearing button3.onClick = attaching edt.onKeyDown = kdown



Process List With Memory Usage.JPG
 Description:
EDITED : More Elegance Process List
 Filesize:  104.78 KB
 Viewed:  2262 Time(s)

Process List With Memory Usage.JPG



AllProcess.JPG
 Description:
All Running Process
 Filesize:  66.57 KB
 Viewed:  2298 Time(s)

AllProcess.JPG



Filtering.JPG
 Description:
Filtering Running Process
 Filesize:  33.19 KB
 Viewed:  2298 Time(s)

Filtering.JPG



_________________
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 Extensions 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