visualc 发表于 2008-11-22 17:07:47

如何用AU3扫描磁盘中的文件~~

就和杀毒软件的形式差不多!!

谢谢~~~~

hhasee 发表于 2009-4-22 13:14:28

学习中,先给你顶一个!

baikaifang 发表于 2009-4-22 20:25:48

提问前请先搜索一下坛论,你的问题可以参考下面这个贴子,http://www.autoitx.com/forum.php?mod=viewthread&tid=1990&highlight=%B1%E9%C0%FA

jycel 发表于 2009-4-22 23:30:40

本帖最后由 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 $searchThen
While 1       
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        $array=StringSplit($file,".")
        $array2=StringSplit($file,"/")
        $stt=$array
        $stt2=$array2
        if $mask<>"" Then
       if $stt=$maskor $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


llztt 发表于 2009-4-22 23:33:54

有人发应过AU3的文件搜索实在是低效。。呵呵

jevonleen 发表于 2009-9-26 01:48:28

路过,帮忙顶一个

kodin 发表于 2009-9-26 02:35:02

:face (14):基本上都是很低效的,试过全盘搜索了一次,然后生成表,足足用了10多分钟时间。。。如果再做个对比,估计更久。

netegg 发表于 2009-9-26 09:37:40

有个api倒是挺快的,忘了怎么用了
页: [1]
查看完整版本: 如何用AU3扫描磁盘中的文件~~