|
#include <GUIConstants.au3>
#notrayicon
dim $ListView1
GUICreate("简单的进程管理器", 257, 364)
$Button1 = GUICtrlCreateButton("结束进程", 8, 328, 105, 25)
$Button2 = GUICtrlCreateButton("刷新列表", 144, 328, 105, 25)
$ListView1 = list()
GUISetState(@SW_SHOW)
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button1
proclose()
Case $msg = $Button2
$ListView1 = list()
EndSelect
WEnd
Exit
func list()
if $ListView1 then GUICtrlDelete($ListView1)
$list = ProcessList()
$ListView1 = GUICtrlCreateListView("进程名 |PID ", 8, 8, 241, 305)
for $i = 1 to $list[0][0] ;进程总数
GUICtrlCreateListViewItem($list[$i][0]&"|"&$list[$i][1],$listview1)
next
return $ListView1
endfunc
func proclose()
$pro = stringsplit(GUICtrlRead(GUICtrlRead($listview1)),"|") //这里是什么意思,为什么需要两个GUICtrlRead命令,返回值的含义又是啥?
if $pro[0] = 2 then
if ProcessExists($pro[2]) then ProcessClose($pro[2]) ;;runwait(@ComSpec & " /c taskkill /f /t /pid " & $pro[2],"",@sw_hide)
else
msgbox(4096,"错误","无法终止进程!")
EndIf
sleep(1000)
if $pro[0] = 2 then
if ProcessExists($pro[2]) then
msgbox(4096,"错误","无法终止进程!")
return
endif
endif
$ListView1 = list()
endfunc |
|