找回密码
 加入
搜索
查看: 1186|回复: 3

谁帮我看下这段代码该如何理解

[复制链接]
发表于 2008-8-18 14:45:14 | 显示全部楼层 |阅读模式
#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
发表于 2008-8-18 15:21:49 | 显示全部楼层
读取$listview1中当前焦点的数据
 楼主| 发表于 2008-8-18 16:37:36 | 显示全部楼层
这个命令我了解,关键是为啥要两个,真奇怪哦,呵呵
发表于 2009-9-1 04:04:41 | 显示全部楼层
很明显这是个错误的代码.....我结束任何东西都结束不了.....那一句的原意是获取pid来终止进程
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-22 21:35 , Processed in 0.071969 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表