#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$i = 0
Opt("GUIOnEventMode", 1)
$Form1_1 = GUICreate("文件复制器", 292, 150, @DesktopWidth / 3, @DesktopHeight / 3)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Label1 = GUICtrlCreateLabel("文件类型 :", 8, 8, 58, 17)
$Combo1 = GUICtrlCreateCombo("所有类型", 72, 8, 73, 25)
$Button1 = GUICtrlCreateButton("设置", 160, 8, 51, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "add_style")
$Label2 = GUICtrlCreateLabel("文件路径 :", 8, 40, 58, 17)
$Input2 = GUICtrlCreateInput("文件路径", 72, 40, 153, 21)
$Button2 = GUICtrlCreateButton("浏览", 232, 40, 51, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "on_event")
$Label3 = GUICtrlCreateLabel("保存路径 :", 8, 72, 58, 17)
$Input3 = GUICtrlCreateInput("保存路径", 72, 72, 153, 21)
$Button3 = GUICtrlCreateButton("浏览", 232, 72, 51, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "on_event")
$Label4 = GUICtrlCreateLabel("文件名称 :", 8, 104, 58, 17)
$Input4 = GUICtrlCreateInput("文件名", 72, 104, 153, 21)
$Button5 = GUICtrlCreateButton("复制", 232, 104, 51, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "on_event")
GUISetState(@SW_SHOW)
start()
While 1
Sleep(1000)
WEnd
Func add_style()
MsgBox(0, '消息', '抱歉,暂无此功能!')
EndFunc ;==>add_style
Func on_event()
Switch @GUI_CtrlId
Case $Button2
$f_sytle = GUICtrlRead($Combo1)
$f_folder = GUICtrlRead($Input2)
If $f_sytle = "所有类型" Then $f_sytle = ".*"
If $f_sytle <> "" And StringLeft($f_sytle, 1) = "." Then
$SF2 = FileSelectFolder("选择文件夹", "", 4 + 2, $f_folder)
If $SF2 <> "" Then
If StringRight($SF2, 1) <> "" Then $SF2 = $SF2 & "" ;读取最右边的字符然后加 “\”
GUICtrlSetData($Input2, $SF2, "")
$search = FileFindFirstFile($SF2 & '*' & $f_sytle)
If $search = -1 Then
MsgBox(0, "错误", "文件夹中没有后缀为" & $f_sytle & "文件", 5)
GUICtrlSetData($Input2, "文件路径", "")
EndIf
EndIf
Else
MsgBox(64, "错误", "没有选择类型或输入错误", 5)
EndIf
Case $Button3
$f_folder = GUICtrlRead($Input2)
$SF3 = FileSelectFolder("选择文件夹", "", 4 + 2, $f_folder)
If $SF3 <> "我的电脑" And $SF3 <> "网上邻居" And $SF3 <> "回收站" And $SF3 <> "" Then
If StringRight($SF3, 1) <> "" Then $SF3 = $SF3 & ""
GUICtrlSetData($Input3, $SF3, "")
EndIf
Case $Button5
$f_sytle = GUICtrlRead($Combo1)
$f_folder = GUICtrlRead($Input2)
$s_folder = GUICtrlRead($Input3)
$filename = GUICtrlRead($Input4)
If $f_folder <> "" And $f_folder <> "文件路径" And $s_folder <> "" And $s_folder <> "保存路径" Then
If $filename = "" Then
MsgBox(0, '错误', '没有指定文件名')
Else
If $f_sytle = "所有类型" Then $f_sytle = ".*"
$search = FileFindFirstFile($f_folder & "*" & $f_sytle)
If $search <> -1 Then
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
$files = StringInStr($file, $filename)
If $files <> 0 Then ;检查是否包含文件名的文件
FileCopy($f_folder & $file, $s_folder, 1)
$i += 1
EndIf
WEnd
If $i <> 0 Then
MsgBox(64, '结果', '成功复制包含文件名为 [' & $filename & '] 共 ' & $i & ' 个文件', 3)
Else
MsgBox(64, '结果', '文件夹中没有包含文件名为 [' & $filename & ']的文件', 3)
EndIf
$i = 0
EndIf
EndIf
Else
MsgBox(64, "错误", "没有选择路径", 5)
EndIf
EndSwitch
EndFunc ;==>on_event
Func start()
GUICtrlSetData($Combo1, ".jpg")
GUICtrlSetData($Combo1, ".gif")
GUICtrlSetData($Combo1, ".txt")
GUICtrlSetData($Combo1, ".mp3")
GUICtrlSetData($Combo1, ".wma")
GUICtrlSetData($Combo1, ".rm")
GUICtrlSetData($Combo1, ".bmp")
GUICtrlSetData($Combo1, ".au3")
GUICtrlSetData($Combo1, ".exe")
GUICtrlSetData($Combo1, ".ico")
EndFunc ;==>start
Func _Exit()
$iAnswer = MsgBox(4 + 256 + 32, "确认", "退出吗?")
Select
Case $iAnswer = 6 ;OK
Exit 0
Case $iAnswer = 7 ;Cancel
EndSelect
EndFunc ;==>_Exit
写这个是因为公司里有些文件夹里的文件很多,用我的电脑打开会很慢,但是每个文件都有关键字存在,用这个程序复制出来就很方便了,但是复制时,点击程序中的关闭按钮就没有反应。