本帖最后由 yhxhappy 于 2010-11-12 16:46 编辑
不太明白楼主的意思,希望以下代码对你有帮助#include <WinAPI.au3>
#Include <WinAPIEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
;创建主窗口
$GUI = GUICreate("EnumWindows", 1000, 700)
;绘制并生成数据表
$listview = GUICtrlCreateListView("", 15, 10, 970, 640)
_GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_REPORT, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_AddColumn($listview, "窗口句柄", 85)
_GUICtrlListView_AddColumn($listview, "窗口标题", 450)
_GUICtrlListView_AddColumn($listview, "窗口文本", 250)
;_GUICtrlListView_AddColumn($listview, "CLASS", 50)
_GUICtrlListView_AddColumn($listview, "PID", 55)
_GUICtrlListView_AddColumn($listview, "进程名称", 100)
;刷新按钮
$Installa_Button = GUICtrlCreateButton("刷新", 835, 655, 150, 35)
AddListviewItem()
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Installa_Button
AddListviewItem()
EndSwitch
WEnd
Func AddListviewItem()
_GUICtrlListView_DeleteAllItems($listview)
$aWindows = _WinAPI_EnumWindows()
For $i = 1 To $aWindows[0][0]
$WindowHandle = $aWindows[$i][0]
$WindowsClass = $aWindows[$i][1]
$WindowTitle = WinGetTitle($aWindows[$i][0])
$WindowText = WinGetText($aWindows[$i][0])
$ProcessPID = WinGetProcess($aWindows[$i][0])
$e = StringSplit(_WinAPI_GetModuleFileNameEx($ProcessPID), "") ;提取进程名称,也可以取进程的路径
$ProcessName = $e[$e[0]]
If $WindowTitle <> "" Then GUICtrlCreateListViewItem($WindowHandle & "|" & $WindowTitle& "|" & $WindowText & "|" & $ProcessPID & "|" & $ProcessName, $listview) ;如果窗口标题为空,则不添加进表格,去掉判断则会全部添加
Next
EndFunc
|