#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 602, 194, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 96, 80, 441, 21)
$Button1 = GUICtrlCreateButton("Button1", 400, 136, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$folder_file = FileSelectFolder('', '')
$aReturn = _FileSearch($folder_file, "специальный документ.txt", 1, 1)
GUICtrlSetData($Input1, $aReturn[1])
EndSwitch
WEnd
Func _FileSearch($sPath, $sFileMask = "*", $iFlag = 0, $iSubDir = 1, $iSort = 0)
Local $sOutBin, $sOut, $aOut, $sRead, $hDir, $sAttrib, $sFiles
If Not StringInStr(FileGetAttrib($sPath), "D") Then
Return SetError(1, 0, 0)
EndIf
If $iSubDir = 1 Then
$sAttrib &= ' /S'
EndIf
If $iSort = 1 Then
$sAttrib &= ' /O:N'
EndIf
Switch $iFlag
Case 1
$sAttrib &= ' /A-D'
Case 2
$sAttrib &= ' /AD'
Case Else
$sAttrib &= ' /A'
EndSwitch
$sOut = StringToBinary('0' & @CRLF, 2)
$sPath = StringRegExpReplace($sPath, '\\+$', '')
$sFileMask = StringRegExpReplace($sFileMask, '^;+|;+$', '')
$sFileMask = StringRegExpReplace($sFileMask, ';{2,}', ';')
$aMasks = StringSplit($sFileMask, ';')
For $i = 1 To $aMasks[0]
If StringStripWS($aMasks[$i], 8) = "" Then
ContinueLoop
EndIf
$sFiles &= '"' & $sPath & '\' & $aMasks[$i] & '"'
If $i < $aMasks[0] Then
$sFiles &= ';'
EndIf
Next
$hDir = Run(@ComSpec & ' /U /C DIR ' & $sFiles & ' /B' & $sAttrib, @SystemDir, @SW_HIDE, 6)
While 1
$sRead = StdoutRead($hDir, False, True)
If @error Then
ExitLoop
EndIf
If $sRead <> "" Then
$sOut &= $sRead
EndIf
WEnd
$aOut = StringRegExp(BinaryToString($sOut, 2), '[^\r\n]+', 3)
If @error Or UBound($aOut) < 2 Then
Return SetError(2, 0, 0)
EndIf
$aOut[0] = UBound($aOut) - 1
Return $aOut
EndFunc ;==>_FileSearch