#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
Local $sItems
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("按后缀找文件", 373, 370, 192, 124)
GUISetBkColor(0xA6CAF0)
$Button1 = GUICtrlCreateButton("查找", 216, 336, 89, 25)
$List1 = GUICtrlCreateList("", 0, 0, 369, 300)
$Label1 = GUICtrlCreateLabel("搜索状态", 8, 344, 196, 17)
$Label2 = GUICtrlCreateLabel("输入要搜索的后缀", 120, 300, 89, 25)
$listmenu1 = GUICtrlCreateContextMenu($List1);给一个控件建上下文菜单(右键菜单)
$menu1 = GUICtrlCreateMenuItem("打开路径", $listmenu1)
$menu2 = GUICtrlCreateMenuItem("复制", $listmenu1)
$menu3 = GUICtrlCreateMenuItem("播放", $listmenu1)
$input1 = GUICtrlCreateInput("", 216, 300, 89, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$houzui = GUICtrlRead($input1)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1
GUICtrlSetData($List1,"")
searchpst(@TempDir&"","*",$houzui);查找后缀名文件;
GUICtrlSetData($Label1,"搜索完成")
Case $menu1
;MsgBox(1,1,GUICtrlRead($List1))
Run("Explorer /select, " & GUICtrlRead($List1))
Case $menu2
ClipPut(GUICtrlRead($List1))
Case $menu3
Run(GUICtrlRead($List1))
EndSwitch
WEnd
Func searchpst($patch,$str,$mask);自定义搜索函数
Local $search,$file,$array,$pst
$search = FileFindFirstFile($patch&$str)
If $search Then
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
$array=StringSplit($file,".")
$pst =$array[UBound($array)-1]
if $pst=$mask Then
GUICtrlSetData($List1,$patch&$file)
GUICtrlSetData($Label1,$patch&$file)
EndIf
if FileChangeDir( $patch&$file)=1 Then
searchpst($patch&$file&"",$str,$mask)
EndIf
WEnd
FileClose($search)
EndIf
EndFunc