process
Platform: mIRC
Published Feb 21, 2012
Updated Feb 23, 2012
builds a list of running processes in the dialogue and the kind of kills the task manager only slightly updated the dead removed from the process of dialogue
dialog test5 {
title "test55"
size -1 -1 180 88
option dbu
list 1, 11 5 155 66, vsbar
button "list", 2, 11 74 30 10
button "clear", 3, 54 74 30 10
button "exit", 4, 137 74 30 10, cancel
button "kill", 5, 96 74 30 10
}
alias test5 {
dialog $iif($dialog(test5),-v,-md) test5 test5
}
menu menubar {
.test55 { test5 }
}
on *:DIALOG:test5:init:0:{ did -b test5 3,5 }
on *:DIALOG:test5:sclick:*:{
if ($did == 2) {
did -e test5 3,5
did -b test5 2
var %x = 1
did -a test5 1 list processes $getinfo(Win32_OperatingSystem,1).NumberOfProcesses
while (%x <= $getinfo(Win32_OperatingSystem,1).NumberOfProcesses ) {
did -a test5 1 $getinfo(Win32_Process,[ %x ]).Caption
inc %x
}
}
if ($did == 3) { did -r test5 1 | did -b test5 3,5 | did -e test5 2 }
if ($did == 5) {
if (!$did(1).seltext) { return }
if (!$did(1).sel) { return }
else { /killprocess 1 $did(1).seltext } { /did -d test5 1 $did(1).sel }
}
}
alias getinfo {
if ($isid) && ($1) && ($prop) {
if ($com(Locator)) { .comclose Locator }
if ($com(Services)) { .comclose Services }
if ($com(Instances)) { .comclose Instances }
.comopen Locator WbemScripting.SWbemLocator
if ($comerr) { .comclose Locator | return }
var %com = $com(Locator,ConnectServer,3,dispatch* Services)
.comclose Locator
if $com(Services) {
var %com = $com(Services, InstancesOf,3,string,$$1,dispatch* Instances)
.comclose Services
}
if $com(Instances) {
var %com = $com(Instances,Count,3)
var %r = $comval(Instances,$iif($2,$2,1),$prop)
.comclose Instances
}
return %r
}
}
alias killprocess {
var %e = echo -ac info * /killprocess:
if ($version < 6.16) { %e snippet requires mIRC 6.35 or higher | return }
if ($1 !isnum 0-) || ($0 < 2) { %e <N> <process> with N zero or higher | return }
var %a = a $+ $ticks, %b = b $+ %a, %c
.comopen %a WbemScripting.SWbemLocator
if ($comerr) { %e error connecting to WMI | return }
.comclose %a $com(%a,ConnectServer,1,dispatch* %b)
if ($com(%b)) .comclose %b $com(%b,ExecQuery,1,bstr*,SELECT $&
Name FROM Win32_Process WHERE Name = $+(",$2-,"),dispatch* %a)
if (!$com(%a)) { %e error retrieving collection | return }
%c = $comval(%a,0)
if (!%c) { %e no such process $2 | return }
if (!$1) {
while (%c) {
!.echo -q $comval(%a,%c,Terminate)
dec %c
}
}
else !.echo -q $comval(%a,$1,Terminate)
:error
if ($com(%a)) .comclose %a
if ($com(%b)) .comclose %b
}
alias processes {
echo -a list processes: $getinfo(Win32_OperatingSystem,1).NumberOfProcesses
var %x = 1
while (%x <= $getinfo(Win32_OperatingSystem,1).NumberOfProcesses) {
echo -a ( $+ %x $+ ) process: $getinfo(Win32_Process,[ %x ]).Caption (priority: $getinfo(Win32_Process,[ %x ]).Priority $+ )
inc %x
}
}