#include <winapi.au3>
#include <GUIConstantsEx.au3>
Opt("GUIDataSeparatorChar", 0)
$CreateName = "程序列表"
$MGUI = GUICreate($CreateName, 300, 120)
$Combo1 = GUICtrlCreateCombo("", 10, 15, 160, 25, 0x0003)
$btn_ok = GUICtrlCreateButton("刷新",200,15,60)
$btn_run = GUICtrlCreateButton("退出",200,60,60)
GUISetState(@SW_SHOW)
while 1
$msg = GUIGetMsg()
Select
Case $msg = $btn_ok
$pList = ProcessList("notepad.exe")
$xx = 0
Dim $arP[$pList[0][0]][2] , $iPID
If $pList[0][0] = 0 Then
MsgBox(0,"错误","没有运行notepad程序")
Else
GUICtrlSetData($Combo1,"")
for $i = 1 to $pList[0][0] step + 1
$wList = WinList()
for $j = 1 to $wList[0][0]
if $wList[$j][0] <> "" And $wList[$j][0] <> "Program Manager" And $wList[$j][0] <> $CreateName And BitAND(WinGetState($wList[$j][1]), 2) Then
_WinAPI_GetWindowThreadProcessId($wlist[$j][1],$iPID)
if not StringCompare($iPID,$pList[$i][1]) Then
$arP[$xx][0] = $wlist[$j][0]
$arP[$xx][1] = $pList[$i][1]
GUICtrlSetData($Combo1,$arP[$xx][0] & " PID: " & $arP[$xx][1])
;MsgBox(0,"",$arP[$k][0]&" IPD:"&$arP[$k][1])
$xx=$xx+1
EndIf
EndIf
Next
Next
EndIf
Case $msg = $Combo1
$comboselect = StringRegExp(GUICtrlRead ( $Combo1 ), 'PID: (\d+)', 1)
MsgBox(64,"已选择项PID为:",$comboselect[0])
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $btn_run
exitLoop
EndSelect
WEnd
Func IsVisible($handle)
If BitAnd( WinGetState($handle), 2 ) Then
Return 1
Else
Return 0
EndIf
EndFunc
|