返回列表 回复 发帖

AU3---简单任务管理器

  1. #include <GUIConstants.au3>
  2. #notrayicon
  3. dim $ListView1
  4. GUICreate("简单的进程管理器", 257, 364)
  5. $Button1 = GUICtrlCreateButton("结束进程", 8, 328, 105, 25)
  6. $Button2 = GUICtrlCreateButton("刷新列表", 144, 328, 105, 25)
  7. $ListView1 = list()
  8. GUISetState(@SW_SHOW)
  9. While 1
  10. $msg = GuiGetMsg()
  11. Select
  12. Case $msg = $GUI_EVENT_CLOSE
  13.   ExitLoop
  14. Case $msg = $Button1
  15.   proclose()
  16. Case $msg = $Button2
  17.   $ListView1 = list()
  18. EndSelect
  19. WEnd
  20. Exit
  21. func list()
  22. if $ListView1 then GUICtrlDelete($ListView1)
  23. $list = ProcessList()
  24. $ListView1 = GUICtrlCreateListView("进程名                              |PID      ", 8, 8, 241, 305)
  25. for $i = 1 to $list[0][0]
  26.   GUICtrlCreateListViewItem($list[$i][0]&"|"&$list[$i][1],$listview1)
  27. next
  28. return $ListView1
  29. endfunc
  30. func proclose()
  31. $pro = stringsplit(GUICtrlRead(GUICtrlRead($listview1)),"|")
  32. if $pro[0] = 2 then
  33.   if ProcessExists($pro[2]) then ProcessClose($pro[2])  ;;runwait(@ComSpec & " /c taskkill /f /t /pid " & $pro[2],"",@sw_hide)
  34.   else
  35.    msgbox(4096,"错误","无法终止进程!")
  36.   EndIf
  37.   sleep(1000)
  38.   if $pro[0] = 2 then
  39.   if ProcessExists($pro[2]) then
  40.   msgbox(4096,"错误","无法终止进程!")
  41.   return
  42. endif
  43. endif
  44. $ListView1 = list()
  45. endfunc
复制代码
感谢Baidu,Google,Dreams8给我这次机会!
还要感谢我的爸爸妈妈!
HOHO
返回列表