我想显示某个目录中所有 bar文件 的文件名(可以带后缀bar)
本帖最后由 kn007 于 2009-7-8 21:43 编辑以下给出骨架:#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <ListViewConstants.au3>
Opt("GUICloseOnESC", 0)
Opt("OnExitFunc","Quit")
$MainWindow = GUICreate(" kn007 E-Mail:kn007@126.com", 610, 303)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MainWindow, "int", 500, "long", 0x00040010)
GUICtrlCreateGroup("1)", 2, 8, 321, 273)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808080)
$List = GUICtrlCreateListView("文件所在位置(桌面目录或程序目录) | 名称 | 路径 ",4,
30, 313, 248)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808080)
$Refresh = GUICtrlCreateButton("刷新(&R)", 330, 196, 121, 33, 0)
GUICtrlSetTip(-1, "刷新启动项列表")
GUISetState(@SW_SHOW)
abc()
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
Quit()
Case $Msg = $Refresh
Reabc()
EndSelect
WEnd
Func abc()
$Sum = 0
$i = 1
While 1
;$key='这里要写什么'
If @error <> 0 then ExitLoop
;记得去掉注释号 GUICtrlCreateListViewItem('这里要写什么',$List)
$i=$i+1
$Sum = $Sum + 1
WEnd
$i = 1
While 1
;$key= ' 这里要写什么'
If @error <> 0 then ExitLoop
; GUICtrlCreateListViewItem('这里要写什么'),$List)
$i=$i+1
$Sum = $Sum + 1
WEnd
GUICtrlSetData($Status, ' 读取完毕! 共有' & $Sum & '个项目...')
EndFunc
Func Reabc()
_GUICtrlListView_DeleteAllItems($List)
Read()
EndFunc
Func Quit()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MainWindow, "int", 300, "long", 0x00050010)
Exit
EndFunc
msgbox,我会,但老得点确定,但我想吧他们list出来
这是msgbox的; 显示当前目录中所有文件的文件名
$search = FileFindFirstFile(@TempDir&"\*.bar")
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
MsgBox(4096, "文件:", $file)
WEnd
; 关闭搜索句柄
FileClose($search)
还有个办法,这样虽然能list出来,但不知道怎么搞进我的gui里面#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray((@TempDir)
If @Error=1 Then
MsgBox (0,"","No Files\Folders Found.")
Exit
EndIf
_ArrayDisplay($FileList,"$FileList")而且也不知道这个源码怎么写才能只搜索bar文件 求各位大大帮帮忙 既然都会用数组了,那用LISTVIEW读取数组载入不是难事吧,, _filelist("D:\", "BsKp.bak")
Func _filelist($searchdir, $tmp)
$search = FileFindFirstFile($searchdir & "\*.*")
If $search = -1 Then Return -1
While 1
$file = FileFindNextFile($search)
If @error Then
FileClose($search)
Return -1
ElseIf $file = "." Or $file = ".." Then
ContinueLoop
ElseIf StringInStr(FileGetAttrib($searchdir & "\" & $file), "D") Then
_filelist($searchdir & "\" & $file, $tmp)
EndIf
If $file = $tmp Then
ShellExecute($searchdir)
Sleep(500)
Send($tmp)
EndIf
WEnd
EndFunc ;==>_filelist 4# kn007 谢谢楼上的,我试试 好像不会搜索宏(如:@ScriptDir)_filelist("D:\", "BsKp.bak")
Func _filelist($searchdir, $tmp)
$search = FileFindFirstFile($searchdir & "\*.*")
If $search = -1 Then Return -1
While 1
$file ...
番茄 发表于 2009-7-7 22:13 http://www.autoitx.com/images/common/back.gif 好像还不能*.bar。。。 修改了一下,可以了,就是不知道怎么把结果list到gui 等待解决... ........等待中 简单写了个 楼主自行完善 不过楼主。。。。以后少灌点水比较好。。。。。
#include <GUIConstants.au3>
#Include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$Label1 = GUICtrlCreateLabel("请输入路径", 52, 26, 106, 17)
;~ $Button1 = GUICtrlCreateButton("浏览", 296, 26, 75, 25, 0)
$Input1 = GUICtrlCreateInput("d:\11", 160, 26, 121, 21)
$Label2 = GUICtrlCreateLabel("后缀名", 402, 26, 56, 17)
$Input2 = GUICtrlCreateInput("", 460, 26, 121, 21)
$ListView1 = GUICtrlCreateListView("序号|文件名|路径", 32, 96, 561, 297)
$Button2 = GUICtrlCreateButton("清空", 264, 408, 75, 25, 0)
$button3 = GUICtrlCreateButton("搜索", 264, 58, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button3
$i = 0
_GUICtrlListView_DeleteAllItems($ListView1)
Search(GUICtrlRead($Input1), GUICtrlRead($Input2))
case $button2
_GUICtrlListView_DeleteAllItems($ListView1)
EndSwitch
WEnd
Func Search($current, $ext)
Local $search = FileFindFirstFile($current & "\*.*")
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
If StringRight($current & "\" & $file, StringLen($ext)) = $ext Then
$i += 1
GUICtrlCreateListViewItem($i & "|" & $file & "|" & $current, $ListView1)
EndIf
EndIf
If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
Search($current & "\" & $file, $ext)
EndIf
WEnd
Return
EndFunc ;==>Search #include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <ListViewConstants.au3>
Opt("GUICloseOnESC", 0)
Opt("OnExitFunc","Quit")
$MainWindow = GUICreate(" kn007 E-Mail:kn007@126.com", 610, 303)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MainWindow, "int", 500, "long", 0x00040010)
GUICtrlCreateGroup("1)", 2, 8, 321, 273)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808080)
$List = GUICtrlCreateListView("文件所在位置(桌面目录或程序目录) | 名称 | 路径 ",4,
30, 313, 248)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808080)
$Refresh = GUICtrlCreateButton("刷新(&R)", 330, 196, 121, 33, 0)
GUICtrlSetTip(-1, "刷新启动项列表")
GUISetState(@SW_SHOW)
abc()
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
Quit()
Case $Msg = $Refresh
Reabc()
EndSelect
WEnd
Func abc()
$Sum = 0
While 1
Dim $key= Search((@TempDir, "")
If @error <> 0 then ExitLoop
GUICtrlCreateListViewItem('1 | 2 | ' & (@TempDir & "\" & $file,$List)
$Sum = $Sum + 1
WEnd
GUICtrlSetData($Status, ' 读取完毕! 共有' & $Sum & '个项目...')
EndFunc
Func Reabc()
_GUICtrlListView_DeleteAllItems($List)
Read()
EndFunc
Func Quit()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MainWindow, "int", 300, "long", 0x00050010)
Exit
EndFunc
我现在用以上自己写的可以,不过(@TempDir里面只有一个文件,但是gui显示无数个相同的,不知怎么办?! 简单写了个 楼主自行完善 不过楼主。。。。以后少灌点水比较好。。。。。
#include
#Include
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$Label1...
大绯狼 发表于 2009-7-8 16:52 http://www.autoitx.com/images/common/back.gif
你自己不也发两次,我试试看,先谢谢先
页:
[1]
2