找回密码
 加入
搜索
查看: 4216|回复: 20

我想显示某个目录中所有 bar文件 的文件名(可以带后缀bar)

[复制链接]
发表于 2009-7-7 19:33:14 | 显示全部楼层 |阅读模式
本帖最后由 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
 
 楼主| 发表于 2009-7-7 19:36:53 | 显示全部楼层
msgbox,我会,但老得点确定,但我想吧他们list出来
这是msgbox的
; 显示当前目录中所有文件的文件名
$search = FileFindFirstFile(@TempDir&"\*.bar")  

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    MsgBox(4096, "文件:", $file)
WEnd

; 关闭搜索句柄
FileClose($search)
 楼主| 发表于 2009-7-7 19:38:10 | 显示全部楼层
还有个办法,这样虽然能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文件
 楼主| 发表于 2009-7-7 19:38:23 | 显示全部楼层
求各位大大帮帮忙
发表于 2009-7-7 22:08:14 | 显示全部楼层
既然都会用数组了,那用LISTVIEW读取数组载入不是难事吧,,
发表于 2009-7-7 22:13:33 | 显示全部楼层
_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

评分

参与人数 1金钱 +4 收起 理由
kn007 + 4 谢谢,不过好像不会搜索宏(如:@ScriptDir ...

查看全部评分

 楼主| 发表于 2009-7-7 22:58:37 | 显示全部楼层
谢谢楼上的,我试试
 楼主| 发表于 2009-7-7 23:09:08 | 显示全部楼层
好像不会搜索宏(如:@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
 楼主| 发表于 2009-7-7 23:13:53 | 显示全部楼层
好像还不能*.bar。。。
 楼主| 发表于 2009-7-7 23:33:51 | 显示全部楼层
修改了一下,可以了,就是不知道怎么把结果list到gui
 楼主| 发表于 2009-7-8 14:10:33 | 显示全部楼层
等待解决...
 楼主| 发表于 2009-7-8 16:36:48 | 显示全部楼层
........等待中
发表于 2009-7-8 16:52:23 | 显示全部楼层
简单写了个 楼主自行完善 不过楼主。。。。以后少灌点水比较好。。。。。
[au3]#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[/au3]
 楼主| 发表于 2009-7-8 16:56:46 | 显示全部楼层
#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显示无数个相同的,不知怎么办?!
 楼主| 发表于 2009-7-8 16:57:32 | 显示全部楼层
简单写了个 楼主自行完善 不过楼主。。。。以后少灌点水比较好。。。。。
[au3]#include
#Include
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$Label1  ...
大绯狼 发表于 2009-7-8 16:52

你自己不也发两次,我试试看,先谢谢先
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-28 02:37 , Processed in 0.086805 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表