Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ProcessMemory(pro)
- f = createForm() f.setSize(300, 150) f.Caption = "Sorted Process List"
- setProperty(f, "BiDiMode", "bdLeftToRight")
- f.Color = 0xFF0000 f.Position = poDesktopCenter
- list = createListBox(f) x, y = f.getSize() list.setSize(x - 10, y - 50) list.setPosition(5, 45) list.OptimalFill = true list.color = 0x00FFFF
- list.Font.Style = "fsBold"
- local lx1 = createLabel(f)
- lx1.AutoSize = false
- lx1.Height = 41
- lx1.Left = 15
- lx1.Top = 1
- lx1.Width = 270
- lx1.Font.Size = 10 lx1.Font.Color = 0xFFFFFF lx1.OptimalFill = true lx1.Font.Style = "fsBold"
- lx1.Alignment = "taCenter"
- lx1.caption = 'Double-click the selection to confirm.\nOnaylamak için, seçimi çift tıklayın.\nPID: - Process: - Memory: '
- function filterprocess()
- local pro = pro..
- ".exe"
- 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 attaching(name)
- local a = list.ItemIndex
- local pro1 = list.Items[a]
- print(pro1)
- pid, mem = pro: match("(.*) -- "..name..
- " - (.*) Kb")
- local pid = pro1: match('%d+');
- pid = tonumber(pid)
- print(pid..
- " - "..name)
- if pid then
- openProcess(pid)
- sleep(200)
- f.Close()
- end
- end
- filterprocess()
- list.onDblClick = function() attaching(pro..
- ".exe") end
- end
- ProcessMemory("chrome")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement