|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Mar 07, 2017 12:03 am Post subject: Function to Sorting Process List |
|
|
Hi there,
Code: | function GetTheProcessList()
local T = {}
local SL=createStringlist()
getProcesslist(SL)
for i=0,strings_getCount(SL)-1 do
T[i] = strings_getString(SL,i)
print(T[i]) -- Output
end
return T
end
GetTheProcessList() |
With function above will listing process running in memory.
How to sort output list using table.sort or foreachinorder(table) by PID or processname with ascending sort order?.
Thanks
--This time I do not know how to do, then I'll know because you have told me what to do
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Tue Mar 07, 2017 5:01 am Post subject: |
|
|
use pl=getProcessList() and then use lua's for pid,name in pl do ...
_________________
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 |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Mar 07, 2017 6:50 am Post subject: |
|
|
Thanks DB
Method 1 : Sorting by pid
Code: | local pl = getProcessList()
local tkeys = {}
for k in pairs(pl) do table.insert(tkeys, k) end
table.sort(tkeys)
for _, k in ipairs(tkeys) do print(k, pl[k]) end
result :
4 System
164 notepad.exe
316 smss.exe
372 nvstreamsvc.exe
444 csrss.exe
448 NvNetworkService.exe
512 taskeng.exe
520 csrss.exe
528 wininit.exe
576 winlogon.exe
624 services.exe
632 lsass.exe
640 lsm.exe
752 svchost.exe
816 nvvsvc.exe
..
..
..
4064 cheatengine-i386.exe |
Method 2 : Sorting by process name
Code: | function getKeysSortedByValue(tbl, sortFunction)
local keys = {}
for key in pairs(tbl) do
table.insert(keys, key)
end
table.sort(keys, function(a, b)
return sortFunction(tbl[a], tbl[b])
end)
return keys
end
pl = getProcessList()
local sortedKeys = getKeysSortedByValue(pl, function(a, b) return a < b end)
for _, key in ipairs(sortedKeys) do
print(key, pl[key])
end
result :
3004 AsusSGPlusBTServer.exe
2892 AsusTPCenter.exe
3672 AsusTPHelper.exe
2444 AsusTPLoader.exe
1960 HD-LogRotatorService.exe
2004 HD-UpdaterService.exe
2596 NvBackend.exe
448 NvNetworkService.exe
..
..
..
..
576 winlogon.exe |
So, then we use the function above to adding items to a combobox or a listbox for sorted process list.
Regards
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Tue Mar 07, 2017 3:21 pm Post subject: |
|
|
If it is for loading Browser processes alike that have many same names instances, it may be better use the form getProcesslist(SL) , since it seems the list preserve the order of process starting. ie. higher index process should be more recently started.
The attached *.lua separated process listing with some filter function and sorting function. For example, instead of sort the process by names, it may be more convenient for the user to filter out those name that's not a target, eg. only keep known browser *.exe named process.
The "order" mention above may be a more useful sorting criteria than by names or by pid number.
Another one may be sort by memory usage of the process, but it may need more work to get this info per pid.
Combine with lesser possible selection (eg. filter by browser names). the user should select the target process more accurately, or your program just select the 1st one list (most recent if by order).
bye~
Description: |
|
Download |
Filename: |
selProcReloaded.lua |
Filesize: |
2.57 KB |
Downloaded: |
534 Time(s) |
_________________
- Retarded. |
|
Back to top |
|
|
akumakuja28 Master Cheater Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Tue Mar 07, 2017 5:57 pm Post subject: |
|
|
Code: |
function GetTheProcessList()
local T = {}
local SL=createStringlist()
getProcesslist(SL)
for i=0,strings_getCount(SL)-1 do
T[i] = strings_getString(SL,i)
-- print(T[i]) -- Output
end
SL = nil
return T
end
function SortByPID(sender) ---- table is sender
local PIDsort = {}
for x = 1, #sender do
PIDsort[x] = sender[x]
end
table.sort(PIDsort)
return PIDsort --- retunr new table preserving old table
end
function SortByName(sender) --sorts table by name with incremental PID's
local A = SortByPID(sender)
local NameSort = {}
local FinalSort = {}
for x = 1,#A do
NameSort[x] = string.sub(A[x],10)..'-'..string.sub(A[x],0,8)
end
table.sort(NameSort) --- table with names first then PID
for x=1, #NameSort do --- FLIP PIDs and Name
FinalSort[x] = string.sub(NameSort[x],-8).."-"..string.sub(NameSort[x],0,-10)
end
A = nil
NameSort = nil
return FinalSort
end
function ReverseOrder(sender)
local RevTable = {}
for x = #sender, 1,-1 do
RevTable[#RevTable+1] = sender[x]
end
return RevTable
end
-----------------------------------------------------------------------------------
------------ Usage Examples ----------------------------------------------------
-----------------------------------------------------------------------------------
PID = GetTheProcessList() --- A is returned table from GetTheProcessList()
Sort = SortByPID(PID) ---- call function with sender (A = table)
NamePid = SortByName(GetTheProcessList())
Rev = ReverseOrder(NamePid)
for x = 1,#PID do
print(PID[x]) ---- prints system table
end
for x = 1,#Sort do
print(Sort[x]) ---- prints system table by PIDs
end
for x = 1,#NamePid do
print(NamePid[x]) ---- prints system table by Soted PID's and Name
end
for x = 1,#Rev do
print(Rev[x]) ---- prints table in Reverse Order
end |
I know how you are attaching to process's and if you decided to use the pair sort it will makes the rest code required to attach to process become cumbersome.
ALSO your sort by name with pairs method returns
--[[ --- Output unsorted by PID
1180 svchost.exe
1580 svchost.exe
1976 svchost.exe
1164 svchost.exe
1912 svchost.exe
]]
Out of order PID's
_________________
Last edited by akumakuja28 on Tue Mar 07, 2017 7:53 pm; edited 1 time in total |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Mar 07, 2017 7:45 pm Post subject: |
|
|
Thanks both of you panraven and akumakuja28
What I am trying to do is make a process list which allow user to attach a process by two methods. First method is by double click on a selected process from process list. This is using 'function pidDialog(doPID)' as you known. (Capture)
And second method is allow user to choose specific process from selection process list provide on a combobox. (Capture 2)
panraven, I will try to implementing your selProcReloaded.lua on my script.
akumakuja28, one line missed on your script
Code: | function SortByPID(sender) ---- table is sender
for x = 1, #sender do
PIDsort[x] = sender[x]
end
table.sort(PIDsort)
return PIDsort --- retunr new table preserving old table
end
--- need add table
local PIDsort = {}
|
Btw, everything work good and I have try to implementing your script on my script too.
Regards
Description: |
|
Filesize: |
34.71 KB |
Viewed: |
9914 Time(s) |
|
Description: |
|
Filesize: |
39.66 KB |
Viewed: |
9915 Time(s) |
|
|
|
Back to top |
|
|
akumakuja28 Master Cheater Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Tue Mar 07, 2017 7:58 pm Post subject: |
|
|
I like what you done to the GUI. looks nice on the eyes.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Mar 07, 2017 8:38 pm Post subject: |
|
|
Thanks akumakuja28
|
|
Back to top |
|
|
|
|
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
|
|