本帖最后由 jycel 于 2009-4-22 23:32 编辑
参照下吧!
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
#include <EditConstants.au3>
$Form1 = GUICreate("搜索工具", 660, 352);, 191, 121)
GUISetBkColor(0xFF0000)
$List1 = GUICtrlCreateList("", 2, 8, 656, 266)
$input1 = GUICtrlCreateInput("", 2, 280, 246, 20,$ES_CENTER)
GUICtrlSetBkColor(-1, 0x7A67EE)
GUICtrlCreateLabel("*请在上面蓝色区域输入文件名或后缀名即可*", 6, 308, 246, 20)
$Button2 = GUICtrlCreateButton("程序说明", 392, 280, 123, 33,$BS_FLAT)
$Button1 = GUICtrlCreateButton("搜索", 262, 280, 123, 33,$BS_FLAT)
$Button3 = GUICtrlCreateButton("退出本程序", 522, 280, 123, 33,$BS_FLAT)
$Label1 = GUICtrlCreateLabel("搜索状态", 6, 322, 636, 34)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button3
exit
Case $Button2
MsgBox(0,"搜索提示","请直接在蓝色区域输入文件名或后缀即可!"&@CRLF&@crlf&"不输任何信息则搜索所有文件")
Case $Button1
GUICtrlSetData($Label1,"搜索中....")
$patch="c:\"
$patch1="d:\"
$lr=GUICtrlRead($input1)
seachfile($patch,"*",$lr);;;;;;;;;查找文件名
seachfile($patch1,"*",$lr);;;;;;;;;查找文件名
GUICtrlSetData($Label1,"搜索完成")
EndSwitch
WEnd
Func seachfile($patch,$str,$mask="")
Local $search,$file,$array,$array2,$stt,$stt2
$search = FileFindFirstFile($patch&$str)
If $search Then
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
$array=StringSplit($file,".")
$array2=StringSplit($file,"/")
$stt=$array[UBound($array)-1]
$stt2=$array2[UBound($array2)-1]
if $mask<>"" Then
if $stt=$mask or $stt2=$mask Then
GUICtrlSetData($List1,$patch&$file)
GUICtrlSetData($Label1,$patch&$file)
EndIf
Else
GUICtrlSetData($List1,$patch&$file)
GUICtrlSetData($Label1,$patch&$file)
EndIf
if FileChangeDir( $patch&$file)=1 and $file<>"." and $file<>".." Then
seachfile($patch&$file&"\",$str,$mask)
EndIf
WEnd
FileClose($search)
EndIf
EndFunc
|