AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1247
|
Posted: Mon Feb 22, 2021 3:08 pm Post subject: All process list example (Edit and archive this) |
|
|
Below is a blended process list table from different codes.
I just ask the masters to edit (shorten and proofread) and assist in creating the final archive.
Please tap this code if you have an idea.
Thanks.
Code: | if form2 then form2.destroy(); form2=nil end
form2 = createForm()
form2.Position = poDesktopCenter
form2.BorderStyle = bsDialog
form2.Width = 290
form2.Height = 300
form2.Caption = "--:-- All Process List Options --:--"
local form2_listbox1 = createListBox(form2)
form2_listbox1.Left = 0
form2_listbox1.Top = 47
form2_listbox1.Width = form2.Width
form2_listbox1.Height = form2.Height - 85
local form2_button1 = createButton(form2)
form2_button1.Left = 5
form2_button1.Top = form2.Height - 32
form2_button1.Width = 95
form2_button1.caption = "All Window List"
local form2_button2 = createButton(form2)
form2_button2.Left = 190
form2_button2.Top = form2.Height - 32
form2_button2.Width = 95
form2_button2.caption = "All Process List"
local form2_button3 = createButton(form2)
form2_button3.Left = 105
form2_button3.Top = form2.Height - 32
form2_button3.Width = 80
form2_button3.caption = "Memory Brow"
local form2_label1 = createLabel(form2)
form2_label1.Alignment="taCenter"
form2_label1.Left = 5
form2_label1.Top = 5
form2_label1.Width = 280
form2_label1.caption = "To activate the process, double click the selection\n(Press the 'F8' key to list the active window)"
form2_label1.Font.Style="fsBold"
form2_label1.Font.Size=9
form2_label1.AutoSize=false
------------------------------------------
local vsblist=1
function foreText()
pid = getForegroundProcess()
local Items = listbox_getItems(form2_listbox1)
strings_clear(Items)
local SL = createStringlist()
getWindowlist(SL)
all_handle = {}
list_process = {}
for i=0, strings_getCount(SL)-1 do
local string_handle = SL[i]
string_handle = string_handle:sub(10, 355)
all_handle[i] = findWindow(nil, string_handle)
--end
--for i=0, #all_handle-1 do
if executeCodeLocal('IsWindowVisible', all_handle[i-1]) == 1 then --User32. all_handle[i]
if vsblist==1 then
strings_add(Items, SL[i-1])
else
PID = tonumber('0x'..SL[i]:sub(1,8));
if pid==PID then
strings_add(Items, SL[i-1])
end
end
end
end
if SL then SL.destroy(); Sl=nil end
end
form2_button2.OnClick=function()
local Items = listbox_getItems(form2_listbox1)
strings_clear(Items)
local SL = createStringlist()
getProcesslist(SL)
--list_process = {}
for i=0, strings_getCount(SL)-1 do
strings_add(Items, SL[i])
end
if SL then SL.destroy(); Sl=nil end
end
--------------------------------------------------------
--Thanks Rafael
SmartAttach =
{
currentprocesslist = {}
}
pro11=""
function SmartAttach:process11(pro11)
if pro11=="" then
wanted_processes = { 'chrome.exe','plugin%-container.exe','Facebook Gameroom Browser.exe',
'Maxthon.exe','opera.exe','brave.exe','firefox.exe','torch.exe' }
else
wanted_processes = { pro11 }
end
return wanted_processes
end
function SmartAttach:Start(wanted11)
pro11=wanted11
SmartAttach:process11(wanted11)
self.form = (form2)
self.combobox = form2_listbox1 --UDF1.CEListBox1
self:Attach(sender)
SmartAttach:RefreshList(wanted11)
end
------------------------------------------
local title=""
function windowTitle(pid)
w=getWindow(getForegroundWindow(), GW_HWNDFIRST)
pid=tonumber(pid)
prs=getWindowProcessID(getWindowCaption(pid))
while w and (w~=0) do
if getWindowProcessID(w)==pid then
result=(getWindowCaption(w)..' ('..getWindowClassName(w)..')')
title=result
end
w=getWindow(w,GW_HWNDNEXT)
end
return result
end
---------------------------------------------
function SmartAttach.SortByKey(T,K,reverse)
if reverse==true then table.sort(T, function (a,b) return a[K] > b[K] end)
else table.sort(T, function (a,b) return a[K] < b[K] end) end
return T
end
function SmartAttach.ProcessMatch(s)
for _,v in pairs(SmartAttach:process11(pro11)) do--SmartAttach.wanted_processes) do
if s:match(v:lower()) then return true end
end
return false
end
function SmartAttach.gatherData()
local handle = io.popen( "tasklist.exe /fo csv" )
local processTable = {}
local skip = true
local tmp = nil
for line in handle:lines() do
if skip then skip = false
else
tmp = {}
for t in line:gmatch('\"(.-)\"') do
table.insert(tmp,t)
end
local processName = tmp[1]
if SmartAttach.ProcessMatch(processName:lower()) then
local PID = tmp[2]
local MemoryUsage = tmp[5]:gsub("[^%d]",'')+0 -- +0 converts to number
local entry = { processName=processName, PID=PID, MemoryUsage=MemoryUsage }
processTable[#processTable+1] = entry
end
end
end
handle:close()
return SmartAttach.SortByKey(processTable,'MemoryUsage',true)
end
function SmartAttach.RefreshList()
local items = SmartAttach.combobox.items
items.clear()
SmartAttach.currentprocesslist = SmartAttach.gatherData()
if ( #SmartAttach.currentprocesslist > 0 ) then
for _,v in ipairs( SmartAttach.currentprocesslist ) do
windowTitle(v.PID)
strings_add(items, string.format('%.1f',v.MemoryUsage/1024)..'MB - '..v.PID..' - '..v.processName)
end
SmartAttach.combobox.ItemIndex = 0
else
return showMessage( "Couldn't find any useful process" )
end
end
function SmartAttach:Attach(sender)
local index = SmartAttach.combobox.ItemIndex
if index < 0 then return end
openProcess( tonumber(SmartAttach.currentprocesslist[index + 1].PID) )
end
-----------------------------------------------------------
form2_button1.OnClick=function()
vsblist=1 foreText()
end
form2_listbox1.OnDblClick=function()
local item = form2_listbox1.ItemIndex
local item1 = form2_listbox1.Items
if item == -1 then return end
local process = item1[item]
process = process:sub(1,8)
process = "0x"..process
process = tonumber(process)
if openProcess(tonumber(process)) then
--form2.Visible = false
else
showMessage("I could not open this transaction")
end
end
form2_button3.OnClick=function() SmartAttach:Start("") end
if frm11 then frm11.destroy() frm11=nil end
frm11=createHotkey(function() sleep(200) vsblist=2 foreText() end, VK_F8)
|
_________________
|
|