[已解决]求助:怎么获取下拉列表框选中项对应的设置值?(不是显示文字)
本帖最后由 zxk123 于 2012-8-14 08:55 编辑我想做个游戏后台自动按键程序,需要用游戏进程句柄,我就想用下拉列表框显示程序名为:notepad.exe的所有窗口名和,选中其中一个窗口名之后再把对应的句柄传给自动按键函数调用。
问题1:怎么获取下拉列表框选中项对应的设置值?(不是显示文字)
问题2:每次按下刷新按钮,列表都刷新,而不是追加?
#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] , $iPID
If $pList = 0 Then
MsgBox(0,"错误","没有运行notepad程序")
Else
for $i = 1 to $pList step + 1
$wList = WinList()
for $j = 1 to $wList
if $wList[$j] <> "" And $wList[$j] <> "Program Manager" And $wList[$j] <> $CreateName And BitAND(WinGetState($wList[$j]), 2) Then
_WinAPI_GetWindowThreadProcessId($wlist[$j],$iPID)
if not StringCompare($iPID,$pList[$i]) Then
$arP[$xx] = $wlist[$j]
$arP[$xx] = $pList[$i]
GUICtrlSetData($Combo1,$arP[$xx] & " PID: " & $arP[$xx])
;MsgBox(0,"",$arP[$k]&"IPD:"&$arP[$k])
$xx=$xx+1
EndIf
EndIf
Next
Next
EndIf
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
#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] , $iPID
If $pList = 0 Then
MsgBox(0,"错误","没有运行notepad程序")
Else
GUICtrlSetData($Combo1,"")
for $i = 1 to $pList step + 1
$wList = WinList()
for $j = 1 to $wList
if $wList[$j] <> "" And $wList[$j] <> "Program Manager" And $wList[$j] <> $CreateName And BitAND(WinGetState($wList[$j]), 2) Then
_WinAPI_GetWindowThreadProcessId($wlist[$j],$iPID)
if not StringCompare($iPID,$pList[$i]) Then
$arP[$xx] = $wlist[$j]
$arP[$xx] = $pList[$i]
GUICtrlSetData($Combo1,$arP[$xx] & " PID: " & $arP[$xx])
;MsgBox(0,"",$arP[$k]&"IPD:"&$arP[$k])
$xx=$xx+1
EndIf
EndIf
Next
Next
EndIf
Case $msg = $Combo1
$comboselect = StringRegExp(GUICtrlRead ( $Combo1 ), 'PID: (\d+)', 1)
MsgBox(64,"已选择项PID为:",$comboselect)
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
页:
[1]