找回密码
 加入
搜索
查看: 1885|回复: 7

[网络通信] 已解决:如何用64位的系统用64位的Autoit 实现"搜索匹配特定名称的文件或子目录....

[复制链接]
发表于 2021-5-28 20:16:44 | 显示全部楼层 |阅读模式
本帖最后由 jiaosc 于 2021-5-29 09:41 编辑

64位的系统用32位的Autoit 以下程序可以正常运行,但换用64位的系统用64位的Autoit 运行不了!请教老师:如何用64位的系统用64位的Autoit 实现"搜索匹配特定名称的文件或子目录的名称 "的功能?
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>

Local $aList[101][2] = [[0]]

Local $tData = DllStructCreate($tagWIN32_FIND_DATA)

Local $sFile
Local $hSearch = _WinAPI_FindFirstFile(@ScriptDir & '\*', $tData)
While Not @error
    $sFile = DllStructGetData($tData, 'cFileName')
    Switch $sFile
        Case '.', '..'

        Case Else
            If Not BitAND(DllStructGetData($tData, 'dwFileAttributes'), $FILE_ATTRIBUTE_DIRECTORY) Then
                $aList[0][0] += 1
                If $aList[0][0] > UBound($aList) - 1 Then
                    ReDim $aList[UBound($aList) + 100][2]
                EndIf
                $aList[$aList[0][0]][0] = $sFile
                $aList[$aList[0][0]][1] = _WinAPI_MakeQWord(DllStructGetData($tData, 'nFileSizeLow'), DllStructGetData($tData, 'nFileSizeHigh'))
            EndIf
    EndSwitch
    _WinAPI_FindNextFile($hSearch, $tData)
WEnd

Switch @extended
    Case 18 ; ERROR_NO_MORE_FILES

    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
        Exit
EndSwitch

_WinAPI_FindClose($hSearch)

_ArrayDisplay($aList, '_WinAPI_Find...', $aList[0][0])
发表于 2021-5-29 00:07:09 | 显示全部楼层
编译64位,尽量使用内置函数实现功能,有一些UDF不支持64位,部分API在64位调用的时候需要使用64位的参数。
发表于 2021-5-29 07:26:19 | 显示全部楼层
 楼主| 发表于 2021-5-29 09:44:27 | 显示全部楼层
本帖最后由 jiaosc 于 2021-5-29 09:53 编辑

回复fybhwsx(UID: 7653037)先生:谢谢您的指导!我的64位的Autoit内没有_FileListEx($sDir)函数,但是有_FileListToArray 函数也可以达到所希望的效果。代码如下:
#include <File.au3>
#include <Array.au3>

Local $FileList = _FileListToArray(@ScriptDir)
If @error = 1 Then
        MsgBox(0, "", "No Folders Found.")
        Exit
EndIf
If @error = 4 Then
        MsgBox(0, "", "No Files Found.")
        Exit
EndIf
;_ArrayDisplay($FileList,"$FileList")
Local $y = ".txt"
Local $a
Local $hangshu = $FileList[0]
For $a = $hangshu To 0 Step -1
        Local $txt = $FileList[$a]
        If StringInStr($txt, $y) = 0   Then
                _ArrayDelete($FileList, $a)
        EndIf
Next
_ArrayToClip($FileList, 1)
发表于 2021-5-29 14:49:42 | 显示全部楼层
jiaosc 发表于 2021-5-29 09:44
回复fybhwsx(UID: 7653037)先生:谢谢您的指导!我的64位的Autoit内没有_FileListEx($sDir)函数,但是有_Fi ...

参加讨论------
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
        ; 使用默认参数返回 desktop(桌面) 目录所有文件和文件夹清单.
        Local $aFiles = _FileListToArray(@ScriptDir, '*.*', 1, True)
        If @error = 1 Then
                MsgBox($MB_SYSTEMMODAL, "", "路径无效.")
                Exit
        EndIf
        If @error = 4 Then
                MsgBox($MB_SYSTEMMODAL, "", "未发现文件.")
                Exit
        EndIf
        Local $imgfile1, $aPA, $iSL
        $sExt = "jpg|ini|exe|txt|au3|xlsx|xls|rar"
        If Not @error Then
                Dim $aPic[UBound($aFiles)], $iSL = 0
                For $ii = 1 To UBound($aFiles) - 1
                        If StringRegExp($aFiles[$ii], '(?i)\.(?:' & $sExt & ")$") Then
                                $aPic[$iSL] = $aFiles[$ii]
                                $iSL += 1
                                ;数组
                                Local $aArray_2D[$iSL]
                                For $i = 0 To UBound($aArray_2D) - 1
                                        $aArray_2D[$i] = $aPic[$i]
                                Next
                        EndIf
                Next
        EndIf
        _ArrayDisplay($aArray_2D, "显示")
EndFunc   ;==>Example
 楼主| 发表于 2021-5-29 16:04:18 | 显示全部楼层

试运行报错,何故?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2021-5-29 16:20:24 | 显示全部楼层
  Local $aFiles = _FileListToArray(@ScriptDir, '*.*', 1, True) 改为:Local $aFiles = _FileListToArray(@ScriptDir, '*.*', 1 )
$sExt = "jpg|ini|exe|txt|au3|xlsx|xls|rar"改为: Local  $sExt = "ini|jpg|ini|exe|txt|au3|xlsx|xls|rar|ini"
运行正常了!OK!
发表于 2021-5-29 17:17:51 | 显示全部楼层
jiaosc 发表于 2021-5-29 16:04
试运行报错,何故?

是版本的问题。
>运行:D:\AutoIt3\autoit3.exe(3.3.14.2)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-4 20:00 , Processed in 0.073938 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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