读取指定扩展名文件并将文件名输出至ComboBox怎么做???[部分源码]
#include <GUIConstantsEx.au3>$Form1 = GUICreate("xx", 535, 454, 193, 115)
GUISetBkColor(0xECE9D8)
$combo2=GUICtrlCreateCombo("", 134, 42, 47,10) ; 创建一个组合列表框(ComboBox)控件
GUICtrlSetData(-1, "", "") ; 在列表框中添加新的项目,并设置一个新的默认值
$btn1=GUICtrlCreateButton("刷新",188,42,47,20)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
;DirRemove($Temp, 1)
Exit
Case $btn1
EndSwitch
WEnd如题,目的是点"点"刷新后搜索指定指定文件夹指定扩展名文件(如.txt),并将文件名输出至ComboBox,尝试过_Find等函数没成功,求指导.... 是这个意思么#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
$Form1 = GUICreate("xx", 535, 454, 193, 115)
GUISetBkColor(0xECE9D8)
$combo2 = GUICtrlCreateCombo("", 20, 42, 100, 20) ; 创建一个组合列表框(ComboBox)控件
GUICtrlSetData(-1, "", "") ; 在列表框中添加新的项目,并设置一个新的默认值
$btn1 = GUICtrlCreateButton("刷新", 188, 42, 47, 20)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
;DirRemove($Temp, 1)
Exit
Case $btn1
_searchfile("d:\myau3\*.au3")
EndSwitch
WEnd
Func _searchfile($path)
GUICtrlSetData($combo2,"")
Local $search = FileFindFirstFile($path)
If Not @error Then
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
_GUICtrlComboBox_AddString($combo2, $file)
WEnd
EndIf
EndFunc ;==>_searchfile 感觉可以用现成的函数FileOpenDialog() 回复 2# zch11230
好使,3Q... 回复 3# shqf
GUICtrlSetData($combo2,FileOpenDialog("XX",@ScriptDir&"\","*.au3"))
无效... #include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <Constants.au3>
$Form1 = GUICreate("xx", 535, 454, 193, 115)
GUISetBkColor(0xECE9D8)
$combo2 = GUICtrlCreateCombo("", 134, 42, 200, 100) ; 创建一个组合列表框(ComboBox)控件
$btn1 = GUICtrlCreateButton("刷新", 388, 42, 47, 20)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
;DirRemove($Temp, 1)
Exit
Case $btn1
_GUICtrlComboBox_BeginUpdate($combo2)
_GUICtrlComboBox_AddDir($combo2, @WindowsDir & "\*.txt")
_GUICtrlComboBox_EndUpdate($combo2)
EndSwitch
WEnd 回复 2# zch11230
哥们,貌似这个只是写至列表框的,我还想设置默认值要咋整???
页:
[1]