1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Bitnugger

Beiträge von Bitnugger

  • Notepad immer über einem AutoIt-Control und Control Größe

    • Bitnugger
    • 13. Februar 2017 um 18:54

    Wie das historisch gewachsen ist, weiß ich nicht... dass müsste man den Entwickler fragen.

    GUICtrlSetPos
    GUI = Graphical User Interface (Grafische Benutzeroberfläche)
    Ctrl = Control (Steuerelement)
    Set = Set (Setzen)
    Pos = Position (Position (und Größe))

    Soweit ich es verstehe, kannst du die mit GUI beginnenden Funktionen nur auf GUIs/Controls anwenden, die du selbst erstellt hast, da du als Parameter für das anzusprechende Control nur die controlID übergibst, für die GUI keinen, denn die stellst du mit GUISwitch() ein, falls du mehrere erstellt hast.

    Bei den mit Control beginnenden Funktionen musst als Parameter für das anzusprechende Control "Title", "Text" und eine controlID angeben... wobei man das nicht zu wörtlich nehmen darf (siehe Title/Text special definition).

    Denn es funktioniert z. B. auch so...

    AutoIt
    Global $hCtrl = ControlGetHandle('', '', '[CLASS:Scintilla; INSTANCE:1]')
    ConsoleWrite("@@ Debug line" & @TAB & @ScriptLineNumber & "   var: $hCtrl --> " & $hCtrl & @CRLF)


    Wie es zu abweichenden Namensbildung für diverse Funktionen kam, ist zumindest für mich nicht nachvollziehbar.
    Z. B. die hier...
    GUICtrlSetPos() <=> ControlMove()

    Wieso bei der einen Funktion SetPos und bei der anderen Move, wenn sie doch beide dieselbe Aufgabe haben?

  • Notepad immer über einem AutoIt-Control und Control Größe

    • Bitnugger
    • 13. Februar 2017 um 16:03
    Zitat von AutoMit

    GUICtrlGetPos - oder was vergleichbares fand ich nicht.

    Bei der Suche in der AutoIt-Hilfe gebe ich den Suchbegriff dann einfach mit * ein... in deinem Fall also: *getpos*
    ControlGetPos.png

  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 10. Februar 2017 um 20:41

    Nun gut... Ich nutze ebenfalls Windows Pro 10 x64. Der Inhalt ist binär und die Datei genau 1 k groß... Google spuckt nichts darüber aus und somit ist das Thema wohl erledigt. Tzz, was es alles gibt...

    1024
    A
    20160915051046
    20160915051046
    20160915051046
    0+>20:20:40 AutoIt3.exe ended.rc:0

  • reguläre Suche - Verzeichnisnamen

    • Bitnugger
    • 10. Februar 2017 um 17:02
    Zitat von chesstiger

    Müsste eigentlich so gehen.

    Im Prinzip schon... allerdings wird hier gar nicht überprüft, ob es sich wirklich um ein Verzeichnis handelt... und ob der letzte Part auch ein Verzeichnis ist, oder doch eine Datei ohne Extension. Verlässlich damit hantieren kann man also nicht. Deshalb habe ich mir die Mühe gemacht und das Ganze ein wenig überarbeitet und auch ein paar alternative Funktionen mit reingepackt, die ich euch nicht vorenthalten wollte.

    PathEx
    AutoIt
    #include <Array.au3>
    #include <String.au3>
    #include <WinAPIShPath.au3>
    
    
    ;-- TIME_STAMP   2017-02-10 16:33:14   v 1.0
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GetPartsOfPath
    ; Description ...: Formats a path to the fully qualified path
    ; Syntax ........: _GetPartsOfPath($sPath[, $bExits = False])
    ; Parameters ....: $sPath               - Eingabepfad.
    ;                  $bExits              - [optional] Specifies whether the path should be existing, valid values:
    ;                                           True - The path must be an existing path, otherwise, the function fails.
    ;                                           False - The path may not exist (Default).
    ; Return values .: Success:             - The formated path.
    ;                  Failure:             - Empty string and sets the @error flag to non-zero.
    ; Author ........: Bitnugger
    ; Modified ......:
    ; Remarks .......: To make sure that $sPath is a fully qualified path, you should first call this function before using another
    ;                  function from this UDF!
    ; Related .......: FileExists()
    ; Link ..........:
    ; Example .......: No
    ; ===============================================================================================================================
    Func _GetPartsOfPath(ByRef $sPath, $bExists = False, $bShowParts = False)
    	Local $sShow = $sPath, $aSplit
    	$sPath = _WinAPI_PathSearchAndQualify($sPath, $bExists)
    	If @error Then Return SetError(1, 0, ConsoleWrite('> ' & $sShow & @CRLF))
    	If $bShowParts Then _PrintParts($sPath, $aSplit)
    	StringReplace($sPath, '\', '')
    	Return (@extended = 0) ? SetError(1, 0, '') : SetError(0, @extended -1, $aSplit)
    EndFunc
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GetNthPartOfPath
    ; Description ...:
    ; Syntax ........: _GetNthPartOfPath($sPath, $n)
    ; Parameters ....: $sPath               - Eingabepfad.
    ;                  $n                   - 0-basierte Nummer des Pfadteiles, der gelesen werden soll.
    ; Return values .: n-ter Teil des Pfades.
    ; Author ........: chesstiger
    ; Modified ......: Bitnugger
    ; Remarks .......: Achtung! Der Laufwerksbuchstabe wird nicht mitgezählt.
    ; Link ..........:
    ; Example .......: No
    ; ===============================================================================================================================
    Func _GetNthPartOfPath($sPath, $n)
    	Local $sPattern = "^[a-zA-Z]:(?:\\.+?){" & $n -1 & "}\\(.+?)(?:\\|$)", $aMatch = StringRegExp($sPath, $sPattern, 3)
    	If Not IsArray($aMatch) Then Return SetError(1, 0, 0)
    	StringReplace($sPath, '\', '')
    	Return SetError(0, (@extended = 0) ? 0 : @extended -1, _WinAPI_PathSearchAndQualify($aMatch[0] & '\', False))
    EndFunc   ;==>_GetNthPartOfPath
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GetNthPartOfPath2
    ; Author ........: Bitnugger
    ; Remarks .......: Alternative function for _GetNthPartOfPath
    ; ===============================================================================================================================
    Func _GetNthPartOfPath2($sPath, $n)
    	Local $x = StringReplace($sPath, '\', ''), $iExt = @extended -1, $iPos1 = StringInStr($sPath, '\', 0, $n), $iPos2 = StringInStr($sPath, '\', 0, $n +1) - $iPos1
    	Return ($iExt < $n Or $iPos1 = 0 Or $iPos2 = 0) ? SetError(1, 0, '') : SetError(0, $iExt, _WinAPI_PathSearchAndQualify(StringMid($sPath, $iPos1 +1, $iPos2 -1) & '\', False))
    EndFunc   ;==>_GetNthPartOfPath2
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GetNthPartOfPath3
    ; Author ........: Bitnugger
    ; Remarks .......: Alternative function for _GetNthPartOfPath
    ; ===============================================================================================================================
    Func _GetNthPartOfPath3($sPath, $n)
    	Local $aString = _StringBetween($sPath, '\', '\'),	$ub = UBound($aString)
    	Return ($ub = 0 Or $ub +1 < $n) ? SetError(1, $n, '') : SetError(0, $ub, _WinAPI_PathSearchAndQualify($aString[$n -1] & '\', False))
    EndFunc   ;==>_GetNthPartOfPath3
    
    
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _RemoveNthPartOfPath
    ; Description ...:
    ; Syntax ........: _RemoveNthPartOfPath($sPath, $n)
    ; Parameters ....: $sPath               - Eingabepfad.
    ;                  $n                   - 0-basierte Nummer des Pfadteiles, der entfernt werden soll.
    ; Return values .: Pfad ohne n-ten Teil.
    ; Author ........: chesstiger
    ; Modified ......: Bitnugger
    ; Remarks .......: Achtung! Der Laufwerksbuchstabe wird nicht mitgezählt.
    ; Related .......:
    ; Link ..........:
    ; Example .......: No
    ; ===============================================================================================================================
    Func _RemoveNthPartOfPath($sPath, $n)
    	Local $sPattern = "^([a-zA-Z]):((?:\\.+?){" & $n -1 & "})(\\.+?)((?:\\.+?)+|$)", $sReplace = "$1:$2$4"
    	$sReturn = StringRegExpReplace($sPath, $sPattern, $sReplace)
    	Return (@error <> 0 Or @extended = 0) ? SetError(@error, 0, '') : SetError(0, @extended +1, _WinAPI_PathSearchAndQualify($sReturn & '\', False))
    EndFunc   ;==>_RemoveNthPartOfPath
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _RemoveNthPartOfPath2
    ; Author ........: Bitnugger
    ; Remarks .......: Alternative function for _RemoveNthPartOfPath
    ; ===============================================================================================================================
    Func _RemoveNthPartOfPath2($sPath, $n)
    	Local $x = StringReplace($sPath, '\', ''), $iExt = @extended, $iPos1 = StringInStr($sPath, '\', 0, $n), $iPos2 = StringInStr($sPath, '\', 0, $n +1)
    	Return ($iExt = 0 Or $iPos2 = 0) ? SetError(1, 0, '') : SetError(0, $iExt -2, _WinAPI_PathSearchAndQualify(StringLeft($sPath, $iPos1 -1) & StringMid($sPath, $iPos2) & '\', False))
    EndFunc   ;==>_RemoveNthPartOfPath2
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _RemoveNthPartOfPath3
    ; Author ........: Bitnugger
    ; Remarks .......: Alternative function for _RemoveNthPartOfPath
    ; ===============================================================================================================================
    Func _RemoveNthPartOfPath3($sPath, $n)
    	Local $aString = StringSplit($sPath, '\', 2), $ub = UBound($aString), _
    		$vRange = ($aString[$ub -1] = '') ? StringFormat('%s;%s', $ub -1, $n) : $n
    	$ub = _ArrayDelete($aString, $vRange)
    	Return ($ub < 0) ? SetError(1, 0, '') : SetError(0, $ub -1, _WinAPI_PathSearchAndQualify(_ArrayToString($aString, '\') & '\', False))
    EndFunc   ;==>_RemoveNthPartOfPath3
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _PrintParts
    ; Author ........: Bitnugger
    ; Remarks .......: Only for debugging...
    ; ===============================================================================================================================
    Func _PrintParts($sPath, ByRef $aSplit)
    	$aSplit = StringSplit($sPath, '\')
    	If $aSplit[$aSplit[0]] = '' Then $aSplit[0] = -1 + _ArrayDelete($aSplit, $aSplit[0] )
    	For $i = 1 To $aSplit[0] Step 1
    		If $i = 1 Then ConsoleWrite(@CRLF & '>   ' & $aSplit[0] & ' Count of splits' & @CRLF)
    		ConsoleWrite(StringFormat('+ %3i %s\n', $i, $aSplit[$i]))
    	Next
    EndFunc   ;==>
    Alles anzeigen
    PathEx_Demo
    AutoIt
    ;-- TIME_STAMP   2017-02-10 16:38:20
    
    
    #include <PathEx.au3>
    
    
    Example(1)
    Example(2)
    Example(3)
    Example(4)
    Example(5)
    
    
    Func Example($n = 1)
    	Local Static $bLoop = False
    	If $bLoop = False Then
    		_SPC()
    		Local $sPath = 'c:Program Files (x86)\AutoIt32SciTE\Properties\\\\properties.hide\\\', $aSplit = _GetPartsOfPath($sPath, True, True) 	; Pfad muss existieren!
    		If @error Then ConsoleWrite($sPath & '! $sPath ist kein gültiger Pfad!' & @CRLF)	; <-- genau hingucken!
    		_SPC()
    	EndIf
    	; Dieser Pfad ist auch nicht korrekt, kann aber repariert werden...
    	Local $iDepth, $sPath = 'c:Program Files (x86)\AutoIt3\SciTE\Properties\\\\properties.hide\\\', $aSplit = _GetPartsOfPath($sPath, True, False) ; $bExists = True, $bShowParts = True
    	If @error Then Exit 1	; kein gültiger Pfad!
    	$iDepth = @extended	; Pfad muss existieren!
    	If $bLoop = False Then
    		ConsoleWrite(StringFormat('> $sPath  = %s\n> $sParts = %s\n+ %s\n', $sPath, $iDepth, '$sPath ist ein gültiger Pfad!'))
    		$bLoop = True
    		_SPC()
    	EndIf
    	_ArrayDisplay($aSplit, '$aSplit')
    	_Print('-', '_GetNthPartOfPath    ', _GetNthPartOfPath($sPath,  $n), $n, $iDepth, @error, @extended, 'chesstiger', 'StringRegExp()')
    	_Print('!', '_GetNthPartOfPath2   ', _GetNthPartOfPath2($sPath, $n), $n, $iDepth, @error, @extended, 'Bitnugger', 'StringReplace() & StringInStr()')
    	_Print('!', '_GetNthPartOfPath3   ', _GetNthPartOfPath3($sPath, $n), $n, $iDepth, @error, @extended, 'Bitnugger', '_StringBetween()')
    	_SPC()
    	; Anzahl der verbliebenen Parts in @extended
    	_Print('+', '_RemoveNthPartOfPath ', _RemoveNthPartOfPath($sPath,  $n), $n, $iDepth, @error, @extended, 'chesstiger', 'StringRegExpReplace')
    	_Print('>', '_RemoveNthPartOfPath2', _RemoveNthPartOfPath2($sPath, $n), $n, $iDepth, @error, @extended, 'Bitnugger', 'StringReplace() & StringInStr()')
    	_Print('>', '_RemoveNthPartOfPath3', _RemoveNthPartOfPath3($sPath, $n), $n, $iDepth, @error, @extended, 'Bitnugger', 'StringSplit()')
    	_SPC()
    EndFunc
    
    
    Func _Print($sColor, $sFunc, $sString, $n, $iDepth, $iError, $iExtended, $sAuthor, $sComment)
    	If $iError Then Return ConsoleWrite('! ' & $sFunc & @TAB & @TAB & 'Ops, der Pfad hat ' & $iDepth & ' Parts, aber $n ist !' & ' ' & $n & @CRLF & '! #Error: ' & $iError & @TAB & '#Extended:' & $iExtended & @CRLF)
    	ConsoleWrite(StringFormat('%s %s|$n = %2i|$iDepth = %2i|Returned Parts in $iExtended = %2i|$sString = %-62s|%-16s|%-36s\r\n', $sColor, $sFunc, $n, $iDepth, $iExtended, $sString, $sAuthor, $sComment))
    EndFunc
    
    
    Func _SPC()
    	ConsoleWrite('------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------' & @CRLF)
    EndFunc
    Alles anzeigen
  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 9. Februar 2017 um 22:43

    Ja, das mit dem $iDiff hatte ich eingebaut, kurz nachdem ich das 1. Bild hochgeladen hatte... da es nun mit dem 2. Bild übereinstimmt. Schaue dir mal die erste Zeile der Ausgsabe an...

    ! $iDiff = 147 C:\Windows\System32\%TMP%
    wird expandiert zu...
    ! $iDiff = 147 C:\Windows\System32\C:\Users\ghost\AppData\Local\Temp


    Da ist doch was faul... :D

  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 9. Februar 2017 um 21:27
    Zitat von autoiter

    @Bitnugger ändere einfach mal die Callback-Funktion. Vielleicht hast du da einfach keine Datei jünger als 14 Tage? Such vllt. mal Stringinstring ".dll"

    Ja danke - stimmt... bin ich vorhin auch selbst drauf gekommen... habe die Funktion cb_MyFunc ein wenig umgestrickt, damit man $iDiff und $s_Path sehen kann.


    AutoIt
    ; Callback-Funktion welche True zurückgibt, wenn eine Datei den Anforderungen entspricht und False wenn nicht
    ; Konkrete Prüfung hier: Test ob Datei jünger als 100 Tage ist:
    Func cb_MyFunc(Const $s_Path)
    	Local Static $Now = _NowCalc(), $iDiff, $sColor, $iMin = 100
    	$iDiff = _DateDiff("D", StringRegExpReplace(FileGetTime($s_Path, 0, 1), "(\d{4})(\d{2})(\d{2}).+", "$1/$2/$3"), $Now)
    	$sColor = ($iDiff < $iMin) ? '+' : '!'
    	ConsoleWrite(StringFormat('%s $iDiff = %6i \t %s\r\n', $sColor, $iDiff, _WinAPI_ExpandEnvironmentStrings($s_Path)))
    	Return ($iDiff < $iMin) ? True : False
    EndFunc   ;==>cb_MyFunc

    Doch was ich noch nicht verstehe, warum im erstes Ergebnis die Umgebungsvariable nicht expandiert wurde...
    ! 147 C:\Windows\System32\%TMP%

    TMP.png

    Habe dann die Zeile geändert... dann passt es.

    AutoIt
    ;Local $aRet = StringSplit(StringTrimRight($sRet, 1), "|", $flgSS)
    Local $aRet = StringSplit(StringTrimRight(_WinAPI_ExpandEnvironmentStrings($sRet), 1), "|", $flgSS)

    Dateien

    TMP2.png 127,83 kB – 0 Downloads
  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 9. Februar 2017 um 19:45
    Zitat von AspirinJunkie

    Hier mal als Beispiel wie ich das meine:

    Oh ja, das ist ein sehr interessanter Ansatz... doch leider funktioniert dein Beispiel nicht.

    Nachdem ich "#include <Array.au3>" hinzugefügt hatte, lief es zwar, doch das Ergebnis-Array ist leer!

  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 9. Februar 2017 um 17:56
    Zitat von autoiter

    PS: Nur ein Vorschlag ...

    Stimmt, denn es heißt ja "...ToArray...". ;)

  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 9. Februar 2017 um 13:15

    So in etwa habe ich mir das vorgestellt...

    _FileListToArrayRecExt()
    AutoIt
    ;-- TIME_STAMP   2017-02-09 13:27:52
    
    
    #include <_FileListToArrayRecExt.au3>
    
    
    Global $g_sNowCalc = _NowCalc(), $g_sNowDate = _NowDate(), $g_sNowTime = _NowTime()
    
    
    _Example_1()
    _Example_2()
    _Example_3()
    _Example_4()
    _Example_5()
    _Example_6()
    _Example_7()
    
    
    Func _Example_1()
    	Local $sFolder           = @ScriptDir
    
    
    	$aFileList = _FileListToArrayRecExt($sFolder)
    	_ArrayDisplay($aFileList, '$aFileList - Example_1')
    EndFunc
    
    
    Func _Example_2()
    	Local $sFolder           = @ScriptDir
    	Local $sStartDate        = _DateAdd('d', -456, $g_sNowCalc)
    
    
    	$aFileList = _FileListToArrayRecExt($sFolder, $sStartDate)
    	_ArrayDisplay($aFileList, '$aFileList - Example_2')
    EndFunc
    
    
    Func _Example_3()
    	Local $sFolder           = @ScriptDir
    	Local $sStartDate        = '2010/05/03'
    	Local $sEndDate          = _DateAdd('d', -123, $g_sNowCalc)
    
    
    	$aFileList = _FileListToArrayRecExt($sFolder, $sStartDate, $sEndDate)
    	_ArrayDisplay($aFileList, '$aFileList - Example_3')
    EndFunc
    
    
    Func _Example_4()
    	Local $sFolder           = @SystemDir
    	Local $sStartDate        = _DateAdd('d', -456, $g_sNowCalc)
     	Local $sEndDate          = ''
    	Local $iDateOpt          = 2
    	Local $iTimestampType    = 1
    	Local $vMask             = '*.exe;*.dll|*|*'
    	Local $iReturn           = $FLTAR_FILES
    	Local $iRecur            = -8
    	Local $iSort             = BitOR($FLTAR_SORT, $FLTAR_SORTBYTIMESPTAMP, $FLTAR_SORTASCENDING)
    	Local $iReturnPath       = $FLTAR_RELPATH
    
    
    	$aFileList = _FileListToArrayRecExt($sFolder, $sStartDate, $sEndDate, $iDateOpt, $iTimestampType, $vMask, $iReturn, $iRecur, $iSort, $iReturnPath)
    	_ArrayDisplay($aFileList, '$aFileList - Example_4')
    EndFunc
    
    
    Func _Example_5()
    	Local $sFolder           = @ProgramFilesDir
    	Local $sStartDate        = '-6m'
    	Local $sEndDate          = '-2d'
    	Local $iDateOpt          = 2
    	Local $iTimestampType    = 0
    	Local $vMask[4][2]       = [[3, ''], [$FLTAR_INCLUDE, '*'], [$FLTAR_EXCLUDE, 'desktop.ini|thumbs.db'], [$FLTAR_EXCLUDE_FOLDERS, 'Microsoft.*|Windows.*|Reference Assemblies']]
    	Local $iReturn           = BitOR($FLTAR_FILES, $FLTAR_NOHIDDEN, $FLTAR_NOSYSTEM, $FLTAR_NOLINK)
    	Local $iRecur            = $FLTAR_RECUR
    	Local $iSort             = BitOR($FLTAR_SORT, $FLTAR_SORTBYTIMESPTAMP)
    	Local $iReturnPath       = $FLTAR_RELPATH
    
    
    	$aFileList = _FileListToArrayRecExt($sFolder, $sStartDate, $sEndDate, $iDateOpt, $iTimestampType, $vMask, $iReturn, $iRecur, $iSort, $iReturnPath)
    	_ArrayDisplay($aFileList, '$aFileList - Example_5')
    EndFunc
    
    
    Func _Example_6()
    	Local $sFolder           = 'c:\|d:\'
    	Local $sStartDate        = _DateAdd('d', -456, $g_sNowCalc)
    	Local $sEndDate          = _DateAdd('d', -123, $g_sNowCalc)
    	Local $iDateOpt          = 2
    	Local $iTimestampType    = 0
    	Local $vMask             = '*'
    	Local $iReturn           = $FLTAR_FOLDERS
    	Local $iRecur            = $FLTAR_NORECUR
    	Local $iSort             = $FLTAR_NOSORT
    	Local $iReturnPath       = $FLTAR_RELPATH
    
    
    	$aFileList = _FileListToArrayRecExt($sFolder, $sStartDate, $sEndDate, $iDateOpt, $iTimestampType, $vMask, $iReturn, $iRecur, $iSort, $iReturnPath)
    	_ArrayDisplay($aFileList, '$aFileList - Example_6')
    EndFunc
    
    
    Func _Example_7()
    	Local $sFolder           = '*'
    	Local $sStartDate        = '2000/01/01 00:00:00'
    	Local $sEndDate          = ''
    	Local $iDateOpt          = 3
    	Local $iTimestampType    = 0
    	Local $vMask             = '*.exe'
    	Local $iReturn           = $FLTAR_FILESFOLDERS
    	Local $iRecur            = -1
    	Local $iSort             = BitOR($FLTAR_SORT, $FLTAR_SORTBYPATH, $FLTAR_SORTBYFILENAME)
    	Local $iReturnPath       = $FLTAR_RELPATH
    	Local $sFileListSavePath = _TempFile()
    
    
    	$aFileList = _FileListToArrayRecExt($sFolder, $sStartDate, $sEndDate, $iDateOpt, $iTimestampType, $vMask, $iReturn, $iRecur, $iSort, $iReturnPath, $sFileListSavePath)
    	If UBound($aFileList) Then
    		Local $iPID = Run(StringFormat('%s "%s"','notepad.exe', $sFileListSavePath), '', @SW_SHOW)
    		ProcessWaitClose($iPID)
    		FileDelete($sFileListSavePath)
    	EndIf
    EndFunc
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _FileListToArrayRecExt
    ; Description ...:
    ; AutoIt Version : 3.3.15.0 (Beta)
    ; Description ...: Lists files with specific age limits
    ; Syntax ........: _FileListToArrayRecExt($sFilePath[, $sStartDate = ''[, $sEndDate = ''[, $iDateOpt = 0[, $iTimestamp = 0[, $sMask = '*'[, $iReturn = $FLTAR_FILESFOLDERS[,
    ;                  $iRecur = $FLTAR_NORECUR[, $iSort = $FLTAR_NOSORT[, $iReturnPath = $FLTAR_RELPATH[, $sFileListSavePath = '']]]]]]]]]])
    ; Parameters ....: $sFilePath           - Name of the directory to be searched
    ;                  $sStartDate          - The file is included in the list if $sTimeStamp is equivalent to $sStartDate and/or $sEndDate,
    ;                  $sEndDate            - where the evaluation is dependent on $iDateOpt
    ;                                         Format = YYYY/MM/DD[ HH:MM:SS]
    ;                                         or the relative time in units, which is then subtracted from _NowCalc()
    ;                                         Valid units of _DateDiff (y = years, m = months, w = weeks, d = days, h = hours, n = minutes, s = seconds)
    ;                                         Examples: 1y, 27m, 154w, 224d, 1734h, 528295n or 1624736s
    ;                  $iDateOpt            - [optional] the file is added to the results list if time stamp of the file...
    ;                                         $DO_ALL .................... ( 0) all files (default)
    ;                                         $DO_EQU .................... ( 1) =  $sStartDate
    ;                                         $DO_LSS .................... ( 2) <  $sStartDate
    ;                                         $DO_GTR .................... ( 3) >  $sStartDate
    ;                                         $DO_LEQ .................... ( 4) <= $sStartDate
    ;                                         $DO_GEQ .................... ( 5) >= $sStartDate
    ;                                         $DO_NEQ .................... ( 6) <> $sStartDate
    ;                                         The remaining flags are ignored if $sStartDate >= $sEndDate
    ;                                         $DO_GTR_LSS ................ ( 7) >  $sStartDate And <  $sEndDate
    ;                                         $DO_GTR_GEQ ................ ( 8) >  $sStartDate And <= $sEndDate
    ;                                         $DO_GEQ_LEQ ................ ( 9) >= $sStartDate And <= $sEndDate
    ;                                         $DO_GEQ_LSS ................ (10) >= $sStartDate And <  $sEndDate
    ;                                         $DO_EQU_EQU ................ (11) =  $sStartDate Or  =  $sEndDate
    ;                                         $DO_LSS_GTR ................ (12) <  $sStartDate Or  >  $sEndDate
    ;                                         $DO_???_???
    ;                  $iTimestampType      - defines which timestamp is used.
    ;                                         $FT_MODIFIED ............... (  0) = Last modified (default)
    ;                                         $FT_CREATED ................ (  1) = Created
    ;                                         $FT_ACCESSED ............... (  2) = Last accessed
    ;                                         $FT_MODIFIEDANDCREATED ..... (  4) = Last modified and Created
    ;                                         $FT_MODIFIEDANDACCESSED .... (  8) = Last modified and Last accessed
    ;                                         $FT_ACCESSEDANDCREATED ..... ( 16) = Last accessed and Created
    ;                                         $FT_ALLTIMESTAMPS .......... ( 32) = all timestamps
    ;                  $iReturn             - [optional] Specifies whether to return files, folders or both and omit those with certain attributes
    ;                                             $FLTAR_FILESFOLDERS .... (  0) - (Default) Return both files and folders
    ;                                             $FLTAR_FILES ........... (  1) - Return files only
    ;                                             $FLTAR_FOLDERS ......... (  2) - Return Folders only
    ;                                         Add one or more of the following to $iReturn to omit files/folders with that attribute
    ;                                             + $FLTAR_NOHIDDEN ...... (  4) - Hidden files and folders
    ;                                             + $FLTAR_NOSYSTEM ...... (  8) - System files and folders
    ;                                             + $FLTAR_NOLINK ........ ( 16) - Link/junction folders
    ;                                         Add one or more of the following to $iReturn to displayed the attribute and/or size from files/folders
    ;                                             $FLTAR_FILESIZE ........ ( 32) - Return file size
    ;                                             $FLTAR_FOLDERSIZE ...... ( 64) - Return folder size
    ;                                             $FLTAR_FILESFOLDERSIZE . (128) - Return file and folder size
    ;                                             $FLTAR_TIMESTAMP ....... (256) - Return timestamp
    ;                                             $FLTAR_COUNT ........... (512) - Return count of files and/or folders
    ;                  $sMask               - [optional] Filter for result. Multiple filters must be separated by ";"
    ;                                         Use "|" to separate 3 possible sets of filters: "Include|Exclude|Exclude_Folders"
    ;                                             Include = Files/Folders to include (default = "*" [all])
    ;                                             Exclude = Files/Folders to exclude (default = "" [none])
    ;                                             Exclude_Folders = only used if $iRecur = 1 AND $iReturn <> 2 to exclude defined folders (default = "" [none])
    ;                                         Alternatively, an array can also be passed...
    ;                                             $iCount = Number of masks
    ;                                             $iMask  = $FLTAR_Include = 0, $FLTAR_Exclude = 1, $FLTAR_Exclude_Folders = 2
    ;                                             $sName  = NAME or PATTERN (*.exe|Microsoft*) of the file or directory to be Include|Exclude
    ;                                             $aMask[$iCount][0]
    ;                                             $aMask[$iMask][$sName]
    ;                                             ...
    ;                  $iRecur              - [optional] Specifies whether to search recursively in subfolders and to what level
    ;                                        $FLTAR_NORECUR .............. (  0) - Do not search in subfolders (Default)
    ;                                        $FLTAR_RECUR ................ (  1) - Search in all subfolders (unlimited recursion)
    ;                                        Negative integer - Search in subfolders to specified depth
    ;                  $iSort               - [optional] Sort results in alphabetical and depth order
    ;                                         $FLTAR_NOSORT .............. (  0) - Not sorted (Default)
    ;                                         $FLTAR_SORT ................ (  1) - Sorted (by NAME)
    ;                                         $FLTAR_FASTSORT ............ (  2) - Sorted (by NAME) with faster algorithm (assumes files in folder returned sorted - requires NTFS and not guaranteed)
    ;                                         $FLTAR_SORTBYPATH .......... (  4) - Sorted (by PATH)
    ;                                         $FLTAR_SORTBYFILENAME ...... (  8) - Sorted (by PATH)
    ;                                         $FLTAR_SORTBYTIMESPTAMP .... ( 16) - Sorted (by TIMESPTAMP)
    ;                                         $FLTAR_SORTDESCENDING ...... (  0) - sort in descending order (Default) / must not be specified (because value = 0)
    ;                                         $FLTAR_SORTASCENDING ....... ( 32) - sort in ascending order
    ;
    ;                  $iReturnPath         - [optional] Specifies displayed path of results
    ;                                         $FLTAR_NOPATH .............. (  0) - File/folder name only
    ;                                         $FLTAR_RELPATH ............. (  1) - Relative to initial path (Default)
    ;                                         $FLTAR_FULLPATH ............ (  2) - Full path included
    ;                  $sFileListSavePath   - Complete path to a text file in which the search results are to be stored. If it is empty, no text file is created.
    ;
    ; Return values .: Success - Depending on the parameters passed, a 1D / 2D array (with 1, 2 or 3 columns) with all found files.
    ;                            $aArray[[COUNT, ]NAME[, SIZE[, TIMESTAMP]] / COUNT, SIZE and TIMESTAMP are optional
    ;                            and file count in @extended
    ;                  Failure - error message
    ;                            and sets the @error flag to non-zero.
    ; Related .......: _FileListToArray, _FileListToArrayRec
    ; Author ........: Bitnugger, ?
    ; Credits........: autoiter, Zeitriss, Melba23 (for _FileListToArrayRec)
    ; Link ..........: https://autoit.de/
    ; Example .......: YES
    ; ==================================================================================================================================================================
    Alles anzeigen
  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 9. Februar 2017 um 03:06
    Zitat von autoiter

    ; $iTimestampType - defines which timestamp is used.
    ; 0 = creation time
    ; 1 = last modification time
    ; 2 = last access time

    Hier hattest du dich übrigens auch vertan...

    Richig ist:

    $FT_MODIFIED (0) = Last modified (default)
    $FT_CREATED (1) = Created
    $FT_ACCESSED (2) = Last accessed

  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 8. Februar 2017 um 16:08
    Zitat von olfibits

    Wie kann ich dieses Format ändern:
    C:\Users\***\Desktop\Sia - Never Give Up.mp3|2017/01/15 11:26

    Zuerst - nein, hier bist du nicht richtig... denn du hast einen fremden Thread gekapert, der mit deiner Frage nichts zu tun hat.

    Hier geht es um das Thema "Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten."

    Du hättest einen eigenen Thread eröffnen müssen... dazu klickst du einfach auf den Button "Neues Thema".

    Zu deiner Frage... das kannst du z. B. so machen:

    AutoIt
    Local $sString  = 'C:\Users\***\Desktop\Sia - Never Give Up.mp3|2017/01/15 11:26'
    Local $sConvert = StringRegExpReplace($sString, '(.+)\|(.+)', '$2 - $1')
    ConsoleWrite('$sString  = ' & $sString & @CRLF)
    ConsoleWrite('$sConvert = ' & $sConvert & @CRLF)
  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 8. Februar 2017 um 00:26

    @Zeitriss

    FileGetTime() - ja, stimmt... und wieder ein Fehler weniger!

    DllCall() vs StringRegExpReplace() - ja, stimmt... doch mit StringRegExp() geht es sogar noch einen Tacken schneller!

    Zitat von Zeitriss

    Beim gesamten Konzept frage ich mich ob eine Funktion, welche Dateien auf einem frei bestimmbaren Zeitraum überprüft nicht deutlich sinnvoller wäre.

    Ja klar... war auch mein erster Gedanke, als ich das Script von @autoiter sah, dachte ich... oh, super, da hat mir einer die Arbeit abgenommen... aber so ganz dann doch nicht. An meiner Funktion bin ich noch am stricken... dauert noch etwas, bis ich sie fertig habe, was ich hier...

    Zitat von Bitnugger

    Hihi... nein, nicht nur kürzen... und jetzt nicht lachen, aber ich war auch dabei mir so eine Funktion zu tippern... und dann sehe ich dann dein Script hier.

    aber auch schon angedeutet hatte.

    Zitat von Zeitriss

    Habe schnell mal hierzu auch mal was zusammen gebastelt, ist allerdings "quick and dirty".

    Grins... "quick and dirty" - so mag ich es beim Sex... doch was meine Scripte angeht, ist es ein absolutes Tabu... :rofl:

    _FileListBetweenDates() - oh ja, und auch wieder eine gute Idee!

    Hm... warum so kompliziert?

    Zitat von Zeitriss

    If Not (0 <= $iTimeStep and $iTimeStep <= 2) Then Return SetError(3)

    If $iTimeStep < 0 Or $iTimeStep > 2 Then Return SetError(3)

    Ich werde mir dein "quick and dirty" aber auch noch mal genauer anschauen...


    @autoiter

    Zitat von autoiter

    mittlerweile habe ich deine Variante mal genauer angeschaut. Viel cooles Zeug für mich dabei!

    Schön... das freut mich sehr... ;)

    Zitat von autoiter

    StringFormat finde ich sehr schön. Ich benutze das viel zu selten ...

    Das ging mir lange Zeit auch so... bis ich dann den Gedankenblitz bekam, dass sich viele Dinge dramatisch optimieren lassen, wenn man sich die Beschreibungen/Kommentare zu den Funktionen genauer anschaut und diese im Hinterkopf behält!!!

    Zitat von autoiter

    Die DLL-Variante in der Funktion __ListFilesByAge_DeletePaths($aReturnedFiles) finde ich interessant. Ich habe es mehrfach mit 10.000 Dateien getestet. Die DLL-Variante ist immer etwas schneller gewesen. In dem Fall zwar nicht die Welt, aber dennoch zu bevorzugen. Wie bist du darauf (shlwapi.dll) gekommen?

    Durch die Funktion _WinAPI_PathStripPath() ; #include <WinAPIShPath.au3>
    Meine Variante...

    AutoIt
    $aReturnedFiles[$i][0] = DllCall($hDll, 'none', 'PathStripPathW', 'wstr', $aReturnedFiles[$i][0])[1]

    ist quasi nur eine verkürzte Form davon... weil in unserem Script ja garantiert ist, dass ein Pfad vorhanden ist, der entfernt werden soll.

    AutoIt
    ; #FUNCTION# ====================================================================================================================
    ; Author.........: Yashied
    ; Modified.......: jpm
    ; ===============================================================================================================================
    Func _WinAPI_PathStripPath($sFilePath)
    	Local $aRet = DllCall('shlwapi.dll', 'none', 'PathStripPathW', 'wstr', $sFilePath)
    	If @error Then Return SetError(@error, @extended, '')
    
    
    	Return $aRet[1]
    EndFunc   ;==>_WinAPI_PathStripPath
    Alles anzeigen
    Zitat von autoiter

    Am geilsten finde ich aber die Geschichte mit den $iAgeAndOlder Fällen!

    Darauf gekommen bin ich durch die Funktion FuncName() - womit dann klar war, dass du Funktionsnamen in eine Variable packen kannst... und die Funktion dann mit dieser Variable aufrufen kannst. Der erste User, bei dem ich gesehen habe, das er das auch kennt, war @4ern.

    Zitat von autoiter

    Streng genommen lässt das noch nicht abgefangene "ym" oder so einen Quatsch zu, ...

    AutoIt
    If StringReplace("dymwhns", $sUnit, '') And @extended <> 1 Then Return SetError(4, "", "Invalid unit")

    Hier hast du einen falschen Gedankengang... StringReplace() liefert in @extended die Anzahl der Ersetzungen... und damit das als Einzeiler funktioniert, mache dann einfach ein If...Then draus... es darf also nur genau 1 Zeichen ersetzt worden sein!

    Zitat von autoiter

    Bei den Bedingungen gibt es noch einen Fehler.

    Oh ja, böder Fehler... <>1... den ich aber schon repariert habe.

    Zitat von autoiter

    Die Funktion hat sich aus einem Fallbeispiel entwickelt, das @Bitnugger sicher auch vor Augen hatte.

    Jeep... stimmt genau!

    Meine Funktion hat momentan folgende Parameter...

    AutoIt
    Func _FileListToArrayRecExt($sFilePath, $sMask = '*', $iReturn = $FLTAR_FILES, $iRecur = $FLTAR_NORECUR, $iSort = $FLTAR_NOSORT, $iReturnPath = $FLTAR_RELPATH, $iDateFlags = $FLTAR_ANY, $sStartDate = '*', $sEndDate = '*', $iDateMode = $FT_MODIFIED)
  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 7. Februar 2017 um 11:19

    Ich habe die Scripts in #Post 2 noch mal stark geändert und noch ein paar Fehler korrigiert...

    Zitat von autoiter

    Die Prüfung würde ich so lassen und stattdessen den gültigen Parameter für alle Dateien auf -1 ändern.

    Die Prüfung hat doch nichts mit dem Parameter für alle Dateien zu tun... $iAge musst du auf 0 setzen, weil 0 Tage ein gülter Wert ist und du sonst ja nicht danach suchen kannst. Die Abfragen habe ich alle noch mal geändert...

    Zitat von autoiter

    Diskutieren möchte ich aber vor Allem die Kürzung des Codes.

    Ja gerne doch...

    Zitat von autoiter

    Du prüfst 5, 500 oder >50.000 mal den Wert der Variable (gerade bei rekursiver Auflistung).

    Jetzt zwar nicht mehr, aber das Abfragen der Variablen geht sicher weitaus schneller, als das Kopieren von großen Arrays... wobei du hier auch wieder das ByRef vergessen hast.

    Zitat von autoiter

    Wolltest du es nur kürzen, oder sollte man zur besseren Übersicht so kurz halten?

    Hihi... nein, nicht nur kürzen... und jetzt nicht lachen, aber ich war auch dabei mir so eine Funktion zu tippern... und dann sehe ich dann dein Script hier. :D

    Seine Programme sollte man nicht nur wegen der besseren Übersicht möglichst kurz halten... denn je größer sie werden, umso zeitraubender wird jede Aktion... das Scrollen im Code, die Fehlersuche, das Starten/Laden... und umso mehr Fehler schleichen sich auch ein. Oft ist es so, dass es mehr Zeit und Hirnschmalz braucht, ein kurzes Programm zu schreiben und man dabei auch schneller in Schräglage geraten kann, da man innerhalb einer kompakten Funktion auf mehr Dinge achten muss, als wenn man für jedes mutierte Problem eine eigene Funktion anlegt. Kurze Programme sind vor allem leichter zu pflegen, lange dafür meist schneller. Ich denke allerdings, dass auch hier die ultimative Grundregel gilt und man den optimalen Punkt in der goldenen Mitte findet.

  • Dateien nach Alter/Bearbeitungszeit/Zugriffszeit auflisten.

    • Bitnugger
    • 7. Februar 2017 um 03:08

    Very nice! ;)

    Im Header fehlt bei "iFullPath" das "$"

    $iAgeAndOlder - 0 = all files .................... ok
    $iAgeAndOlder - 1 = all files older than $iAge ... $iDateCalcDay >= $iAge --> all files older than $iAge or the same as $iAge
    $iAgeAndOlder - 2 = all files newer than $iAge ... $iDateCalcDay <= $iAge --> all files newer than $iAge or the same as $iAge

    Hier muss < 0 hin.. nicht = 0

    AutoIt
    If Number($iAge) < 0 Then Return SetError(1, "", "Invalid value for $iAge")

    Hier fragst du 2x "m" ab... das 2-te m muss ein n sein...

    AutoIt
    If $sUnit <> "d" And $sUnit <> "y" And $sUnit <> "m" And $sUnit <> "w" And $sUnit <> "h" And $sUnit <> "m" And $sUnit <> "s" Then ConsoleWrite("Invalid unit" & @CRLF)

    Hm, die drei Funktionen sind ja fast identisch...

    __ListFilesByAge_AllFiles() ; hier wird $iAge als Parameter mit angegeben, in der Funktion aber nicht genutzt...
    __ListFilesByAge_OldFiles()
    __ListFilesByAge_NewFiles()

    somit lässt sich das auch leicht in einer Funktion erledigen, womit du das Script drastisch verkürzen kannst...

    __ListFilesByAge()
    AutoIt
    ;-- TIME_STAMP   2017-02-07 10:13:55
    
    
    #include-once
    #include <File.au3>
    #include <Date.au3>
    
    
    ; #FUNCTION# =======================================================================================================================================================
    ; Title .........: _ListFilesByAge
    ; AutoIt Version : 3.3.15.0 (Beta)
    ; Description ...: Lists files with specific age limits
    ; Syntax.........: _ListFilesByAge( $sSearchFolder [, $iAge = -1 [, $iAgeAndOlder = 1 [, $iSort = 0 [, $sUnit = "d" [, $iRecursiveSearch = 0 [, $iFullPath = 1 [, $sFileListFullPath = ""]]]]]]] )
    ; Parameters ....: $iAge                - Name of the service.
    ;                  $iAgeAndOlder 		- 0 = all files
    ;                                  	  	  1 = only files older or same old as $iAge
    ;                                  	  	  2 = only files newer or same old as $iAge
    ;                                  	  	  3 = only files older than $iAge
    ;                                  	  	  4 = only files newer than $iAge
    ;                  $iSort		 		- 0 = no sorting
    ;                                  	  	  1 = sort in descending order
    ;                                  	  	  2 = sort in ascending order
    ;                  $sUnit		 		- time unit. Valid units of _DateDiff (y = years, m = months, w = weeks, d = days, h = hours, n = minutes, s = seconds)
    ;                  $iTimestampType		- defines which timestamp is used.
    ;                                  	  	  0 = creation time
    ;                                  	  	  1 = last modification time
    ;                                  	  	  2 = last access time
    ;                  $iRecursiveSearch	- 0 = only files in given folder
    ;                                  		  1 = lists files in given folder and files in subfolders
    ;                  $iFullPath		 	- 0 = file name only
    ;                                  		  1 = full file path
    ;                  $sFileListFullPath	- full path to a text file, with all found files. If empty, no textfile ist created.
    ;
    ; Return values .: Success - array with all found files.
    ;                  Failure - error message
    ;                            Sets the @error flag to non-zero.
    ; Author ........: autoiter
    ; Link ..........:
    ; Example .......:
    ;~ Local $aReturnedFiles = _ListFilesByAge(@DesktopDir, 5, 1, 2, "d", 1, 0, 1)
    ;~ If @error Then MsgBox(0, @error, $aReturnedFiles)
    ;~ _ArrayDisplay($aReturnedFiles)
    ; ==================================================================================================================================================================
    Func _ListFilesByAge($sSearchFolder, $iAge = -1, $iAgeAndOlder = 1, $iSort = 0, $sUnit = "d", $iTimestampType = 0, $iRecursiveSearch = 0, $iFullPath = 1, $sFileListFullPath = "")
    	If $iSort < 0 Or $iSort > 2 Then Return SetError(3, "", "Invalid value for $iSort")
    	If IsInt($iAge) = 0 Or $iAge < 0 Then Return SetError(1, "", "Invalid value for $iAge")
    	If StringReplace("dymwhns", $sUnit, '') And @extended <> 1 Then Return SetError(4, "", "Invalid unit")
    	If $iAgeAndOlder < 0 Or $iAgeAndOlder > 4 Then Return SetError(2, "", "Invalid value for $iAgeAndOlder")
    	If $iTimestampType <> 0 Or $iTimestampType > 2 Then Return SetError(5, "", "Invalid value for $iTimestampType")
    	If $iRecursiveSearch < 0 Or $iRecursiveSearch > 2 Then Return SetError(6, "", "Invalid value for $iRecursiveSearch")
    
    
    	If $sFileListFullPath <> "" Then
    		Local $hFileOpen = FileOpen($sFileListFullPath, 10)
    		If @error Then Return SetError(8, "", "FileOpen error. Couldn't create: " & $sFileListFullPath)
    	EndIf
    
    
    	Local $aFiles = _FileListToArrayRec($sSearchFolder, "*", $FLTAR_FILES, $iRecursiveSearch, 0, $FLTAR_FULLPATH)
    	Local $iError = @error
    	If $iError Then
    		If $sFileListFullPath <> "" Then
    			FileClose($hFileOpen)
    			FileDelete($sFileListFullPath)
    		EndIf
    		Return SetError(9, "", "_FileListToArrayRec error. Error value: " & $iError)
    	EndIf
    
    
    	Local $aReturnedFiles[$aFiles[0]][3]
    
    
    	$aReturnedFiles = __ListFilesByAge($aFiles, $iAge, $iAgeAndOlder, $sUnit, $iTimestampType, $aReturnedFiles)
    
    
    	If $aReturnedFiles = 0 Then Return SetError(10, "", "No hits")
    
    
    	$iSort = ($iSort = 0) ? -1 : ($iSort = 1) ? 0 : 1
    	If $iSort >= 0 Then _ArraySort($aReturnedFiles, $iSort, 0, 0, 2)
    	_ArrayColDelete($aReturnedFiles, 2)
    
    
    	If $iFullPath = 0 Then $aReturnedFiles = __ListFilesByAge_DeletePaths($aReturnedFiles)
    
    
    	If $sFileListFullPath <> "" Then
    		_FileWriteFromArray($hFileOpen, $aReturnedFiles)
    		FileClose($hFileOpen)
    	EndIf
    
    
    	Return SetError(0, $aFiles[0], $aReturnedFiles)
    EndFunc   ;==>_ListFilesByAge
    
    
    ; #following funtions internal use only# ===========================================================================================================
    Func __ListFilesByAge(ByRef $aFiles, $iAge, $iAgeAndOlder, $sUnit, $iTimestampType, $aReturnedFiles)
    	Local Static $aFx = [_F0, _F1, _F2, _F3, _F4]
    	Local $sFx = $aFx[$iAgeAndOlder], $aFileTime, $sFileTime, $iDateCalc, $iCount = 0
    
    
    	For $i = 1 To $aFiles[0]
    		$aFileTime = FileGetTime($aFiles[$i], $iTimestampType)
    		$sFileTime = StringFormat('%s/%s/%s %s:%s', $aFileTime[0], $aFileTime[1], $aFileTime[2], $aFileTime[3], $aFileTime[4], $aFileTime[5])
    		$iDateCalcDay = _DateDiff($sUnit, $sFileTime, _NowCalc())
    		$iDateCalcSec = _DateDiff('s', $sFileTime, _NowCalc())
    		If $sFx($iDateCalcDay, $iAge) Then
    			$aReturnedFiles[$iCount][0] = $aFiles[$i]
    			$aReturnedFiles[$iCount][1] = $sFileTime
    			$aReturnedFiles[$iCount][2] = $iDateCalcSec
    			$iCount += 1
    		EndIf
    	Next
    
    
    	If $iCount = 0 Then Return 0
    	ReDim $aReturnedFiles[$iCount][3]
    	Return $aReturnedFiles
    EndFunc   ;==>__ListFilesByAge
    
    
    ; all files
    Func _F0(ByRef $iDateCalcDay, ByRef $iAge)
    	Return True
    EndFunc   ;==>_F0
    ; older or same old files as $iAge
    Func _F1(ByRef $iDateCalcDay, ByRef $iAge)
    	Return $iDateCalcDay >= $iAge
    EndFunc   ;==>_F1
    ; newer or same old files as $iAge
    Func _F2(ByRef $iDateCalcDay, ByRef $iAge)
    	Return $iDateCalcDay <= $iAge
    EndFunc   ;==>_F2
    ; older files than $iAge
    Func _F3(ByRef $iDateCalcDay, ByRef $iAge)
    	Return $iDateCalcDay > $iAge
    EndFunc   ;==>_F3
    ; newer files than $iAge
    Func _F4(ByRef $iDateCalcDay, ByRef $iAge)
    	Return $iDateCalcDay < $iAge
    EndFunc   ;==>_F4
    
    
    Func __ListFilesByAge_DeletePaths($aReturnedFiles)
    	Local $hDll = DllOpen('shlwapi.dll')
    	For $i = 0 To UBound($aReturnedFiles) - 1
    		$aReturnedFiles[$i][0] = DllCall($hDll, 'none', 'PathStripPathW', 'wstr', $aReturnedFiles[$i][0])[1]
    	Next
    	DllClose($hDll)
    	Return $aReturnedFiles
    EndFunc   ;==>__ListFilesByAge_DeletePaths
    Alles anzeigen
    __ListFilesByAge_Example()
    AutoIt
    ;-- TIME_STAMP   2017-02-07 04:43:08   v 0.1
    
    
    #include <File.au3>
    #include <Array.au3>
    #include<_ListFilesByAge.au3>
    
    
    ; #FUNCTION# =======================================================================================================================================================
    ; Title .........: _ListFilesByAge
    ; AutoIt Version : 3.3.15.0 (Beta)
    ; Description ...: Lists files with specific age limits
    ; Syntax.........: _ListFilesByAge( $sSearchFolder [, $iAge = -1 [, $iAgeAndOlder = 1 [, $iSort = 0 [, $sUnit = "d" [, $iRecursiveSearch = 0 [, $iFullPath = 1 [, $sFileListFullPath = ""]]]]]]] )
    ; Parameters ....: $iAge			- Name of the service.
    ;                  $iAgeAndOlder 		- 0 = all files
    ;                                  	  	  1 = only files older or same old as $iAge
    ;                                  	  	  2 = only files newer or same old as $iAge
    ;                                  	  	  3 = only files older than $iAge
    ;                                  	  	  4 = only files newer than $iAge
    ;                  $iSort		 	- 0 = no sorting
    ;                                  	  	  1 = sort in descending order
    ;                                  	  	  2 = sort in ascending order
    ;                  $sUnit		 	- time unit. Valid units of _DateDiff (y = years, m = months, w = weeks, d = days, h = hours, n = minutes, s = seconds)
    ;                  $iTimestampType		- defines which timestamp is used.
    ;                                  	  	  0 = creation time
    ;                                  	  	  1 = last modification time
    ;                                  	  	  2 = last access time
    ;                  $iRecursiveSearch		- 0 = only files in given folder
    ;                                  		  1 = lists files in given folder and files in subfolders
    ;                  $iFullPath		 	- 0 = file name only
    ;                                  		  1 = full file path
    ;                  $sFileListFullPath		- full path to a text file, with all found files. If empty, no textfile ist created.
    ;
    ; Return values .: Success - array with all found files.
    ;                  Failure - error message
    ;                            Sets @error = 1
    ; Author ........: autoiter
    ; Link ..........:
    ; Example .......:
    ;~ Local $aReturnedFiles = _ListFilesByAge(@DesktopDir, 5, 1, 2, "d", 1, 0, 1)
    ;~ If @error Then MsgBox(0, @error, $aReturnedFiles)
    ;~ _ArrayDisplay($aReturnedFiles)
    ; ==================================================================================================================================================================
    
    
    Global $aDisplay = ['all files', 'files older or same old as', 'files newer or same old as', 'files older than', 'files newer than']
    
    
    Global $sSearchFolder = @TempDir, $iAge = 1, $iAgeAndOlder = 2, $iSort = 0, $sUnit = "d", $iRecursiveSearch = 1, $iFullPath = 1, $sFileListFullPath = "m:\FileList.txt"
    
    
    Global $sDisplay, $aReturnedFiles = _ListFilesByAge($sSearchFolder, $iAge, $iAgeAndOlder, $iSort = 0, $sUnit, $iRecursiveSearch, $iFullPath, $sFileListFullPath)
    If @error Then
    	ConsoleWrite("!@ " & @TAB & "#Error: " & @error & @CRLF)
    Else
    	Global $iExtended = @extended, $iUBound = UBound($aReturnedFiles)
    	_ArrayAdd($aReturnedFiles, '________________________________________________________________')
    	_ArrayDisplay($aReturnedFiles, StringFormat('%i/%i %s %s %s', $iUBound, $iExtended, $aDisplay[$iAgeAndOlder], $iAge, $sUnit))
    EndIf
    Alles anzeigen
  • Passwortgeschützte Dateien öffnen

    • Bitnugger
    • 6. Februar 2017 um 13:07

    Hier mal ein Beispiel wie es mit Access geht...

    Access_SetPW
    AutoIt
    ;-- TIME_STAMP   2017-02-06 13:04:57
    
    
    #include <WinAPISys.au3>
    #include <Array.au3>
    
    
    ; ******************************************************************************
    ; DB mit ShellEcecute() oder ... öffnen - Access fragt dann nach dem Passwort...
    ; ******************************************************************************
    
    
    ; Einfache Verschlüsselung ;-)
    Global $sPW = BitXOR('435', 456)	; PW = 123
    ConsoleWrite($sPW & @CRLF)
    
    
    Global $hAccess = WinGetHandle('[TITLE:Access; CLASS:OMain]')
    If Not IsHWnd($hAccess) Then Exit MsgBox(0, @ScriptName, 'Access-Handle nicht gefunden!') +1
    ConsoleWrite('$hAccess = '  & $hAccess & @CRLF)
    
    
    ;_ShowChildWindows()	; Brauchen wir doch nicht...
    
    
    Global $hStatic2 = ControlGetHandle('Kennwort erforderlich', 'Datenbankkennwort eingeben', '[CLASS:Static; INSTANCE:2]')	; Label
    If Not IsHWnd($hStatic2) Then Exit MsgBox(0, @ScriptName, 'Access - "Static2" nicht gefunden!') +3
    ConsoleWrite('$hStatic2 = ' & $hStatic2 & @CRLF)
    
    
    Global $hRichEdit20W1 = ControlGetHandle('Kennwort erforderlich', '', '[CLASS:RichEdit20W; INSTANCE:1]')	; hier musss das Passwort rein!
    If Not IsHWnd($hRichEdit20W1) Then Exit MsgBox(0, @ScriptName, 'Access - "RichEdit20W1" nicht gefunden!') +3
    ConsoleWrite('$hRichEdit20W1 = ' & $hRichEdit20W1 & @CRLF)
    
    
    Global $iSend = ControlSend($hRichEdit20W1, '', '', '123' & '{ENTER}')
    If $iSend = 0 Then Exit MsgBox(0, @ScriptName, 'Access - Senden an "RichEdit20W1" hat nicht geklappt!') +4
    
    
    ConsoleWrite('Das Passwort sollte angekommen sein und die DB nun editierbar sein' & @CRLF)
    
    
    Func _ShowChildWindows()
    	Local $aChildWindows = _WinAPI_EnumChildWindows($hAccess)
    	If $aChildWindows[0][0] = 0 Then Exit MsgBox(0, @ScriptName, 'Access-ChildWindows nicht gefunden!') +2
    	ConsoleWrite('$aChildWindows[0][0] = ' & $aChildWindows[0][0] & @CRLF & @CRLF)
    	For $i = 1 To $aChildWindows[0][0] Step 1
    		Local $hCtrl = $aChildWindows[$i][0]
    		Local $sClassName = $aChildWindows[$i][1]
    		Local $sCtrlText = StringStripWS(ControlGetText('', '', $hCtrl), 8)
    		Local $sWinText = StringStripWS(StringLeft(WinGetText($hCtrl), 26) & '...', 8)
    		Local $sTitle = StringStripWS(StringLeft(WinGetTitle($hCtrl), 26) & '...', 8)
    		ConsoleWrite(StringFormat('$hCtrl: %10s    $sClassName: %-28s    $sCtrlText: %-28s    $sWinText: %-28s    $sTitle: %-28s', $hCtrl, $sClassName, $sCtrlText, $sWinText, $sTitle) & @CRLF)
    	Next
    EndFunc
    Alles anzeigen
  • Passwortgeschützte Dateien öffnen

    • Bitnugger
    • 6. Februar 2017 um 10:34
    Zitat von Kinemod

    Sagen wir ich habe eine Eingabemaske mit Autoit erstellt und die Eingaben werden in eine kleine passwortgeschützte Datenbank (Access oder so) geschrieben.

    Ja und dann? Soll Access die Passwörter schützen? Das kannst du mit AutoIt auch sehr gut machen. Dafür gibt es z. B. die Funktionen _Crypt_EncryptData() und _Crypt_DecryptData()

    Die essentielle Frage ist jedoch, welches Programm und welchen Datentyp du am Ende benutzt, wodurch sich mehrere Lösungsansätze ergeben, wie man das dann bewerkstelligen kann.

    Send() ist eine dieser Möglichkeiten... es geht je nach Fall sicher auch mit ControlSetText() oder _SendMessage()... bzw. mit _FileDragDrop()... oder man kann das Programm mit speziellen Parametern starten... doch ohne einen konkreten Fall führt das hier ins Nirwana! Im Prinzip sind es lediglich 'sensible' Informationen, die du von A nach B bekommen musst... dies geht allerdings nur dann, wenn B dafür eine Möglichkeit bietet.

  • Passwortgeschützte Dateien öffnen

    • Bitnugger
    • 6. Februar 2017 um 06:12

    Hier hast du mal einen groben Ansatz wie man das angehen könnte... der ist allerdings schon stark angestaubt und auch extrem verbesserungsbedürftig.

    Automatische PDF-Passworteingabe

    Wie @water schon sagte, die Lösung hängt immer vom Dateityp und der dafür verwendeten Software ab, mit dem dieser geöffnet werden soll.

    Ich habe mir z. B. ein Script geschrieben, mit dem ich den PAGEANT von Putty beim Systemstart aufrufe und ihm die Passphrasen für meine RSA-Keys übergebe. Denn das sind mal ein paar und die sind ätzend lang... mindestens 64 Zeichen! Die speichere ich dann 2x verschlüsselt in ein IniFile ab und kann sie dann wahlweise mit oder ohne Masterpasswort entschlüsseln und an PAGEANT übergeben.

    Hier mal eine abgespeckte und leicht zu verstehende Version ohne Verschlüsselung... vom Prinzip her auch auf PDF bzw. Adobe Reader usw. anwendbar.

    PAGENTX
    AutoIt
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseUpx=y
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    
    
    ;-- TIME_STAMP   2016-09-28 12:08:38
    
    
    #include <Array.au3>
    #include <WinAPI.au3>
    
    
    _Main()
    
    
    Func _Main()
    	Local $aKey = ['rsa-key-20161201-gast.ppk', 'rsa-key-20161201-batch.ppk', 'rsa-key-20161201-root.ppk', 'rsa-key-20161201-User.ppk', 'rsa-key-20161210-VM.ppk']
    	Local $sKey = _ArrayToString($aKey, ' ')
    	Local $hPAGEANT, $sWinText, $sKeyName, $bIsKey
    	Local $sPageantWinTitle = 'Pageant: Enter Passphrase'
    	Local $idPageantEdit1 = 102
    
    
    	Local $iPID = Run('"c:\Program Files (x86)\TC UP\Plugins\Tools\Putty\PAGEANT.EXE" ' & $sKey, _WinAPI_ExpandEnvironmentStrings('%MPK%'), @SW_SHOW)
    	$aKey = ''
    
    
    	Local $aPP = [	['rsa-key-20161210-VM',		'xAx7dJOkgtrO&dsUzrHM4AZwwOvvOd%wOEbwOrzes3$RGNs&&wOJXwXE5NxkJPzg'], _
    			['rsa-key-20161201-User',	'8UICcb$7Ed4#o#RW2RF9AG$ipJrb2$Px#S##n8gb8Mj9tKSdMXGdzK6hgscXhD%T'], _
    			['rsa-key-20161201-root',	'i9%2ebEAGMJdGDeu8Qr7fL82OikALmHGNs&&QPn$RwOJXwXE5N4JPz9jANbb84O4'], _
    			['rsa-key-20161201-batch',	'Y8GtPubzrHM4AM89dsUZvOd%q5L8&h77wMgAGQl2qbcUWNSzSjIP9oUC4&z#pKdK'], _
    			['rsa-key-20161201-gast',	'CDHUoZJtd$Cil26IrItreJKqMF$9CfzwG4JLLhncRdkt9%XtoEq4Q7NneRDCr4ZI']]
    
    
    	For $i = UBound($aPP) -1 To 0 Step -1
    		$hPAGEANT = WinWaitActive($sPageantWinTitle, '', 3)
    		If $hPAGEANT = 0 Then Exit 1
    		$sWinText = WinGetText($sPageantWinTitle)
    		$sKeyName = StringSplit($sWinText, @LF)[2]
    		If $sKeyName = "" Then Exit 2
    		$bIsKey = ($sKeyName = $aPP[$i][0])
    		If $bIsKey = False Then _CW(StringFormat('! "%-30s" "%-30s" = %-5s', $sKeyName & '.ppk', $aPP[$i][0], ($sKeyName & '.ppk' = $aPP[$i][0] & '.ppk')) & @CRLF)
    		If $bIsKey = True Then
    			_CW(StringFormat('+ %-30s %-30s = %-5s', '"' & $sKeyName & '.ppk', $aPP[$i][0], ($sKeyName & '.ppk' = $aPP[$i][0] & '.ppk')) & @CRLF)
    			_CW('ControlSetText ' & $aPP[$i][1] & ' = ' & ControlSetText($sPageantWinTitle, '', $idPageantEdit1, $aPP[$i][1], $SEND_RAW) & @CRLF)
    			Send('{Enter}')
    			_ArrayDelete($aPP, $i)
    		EndIf
    	Next
    EndFunc
    
    
    Func _CW($sString)
    	If @Compiled = 0 Then ConsoleWrite($sString)
    EndFunc
    Alles anzeigen
  • unable to use the DLL file

    • Bitnugger
    • 4. Februar 2017 um 07:12

    Wenn du uns dein Script zeigst, können wir dir sicher helfen...

    Zitat von flockZ

    unable to use the DLL file

    Das kann viele Gründe haben - doch ohne :Glaskugel: macht es wenig Sinn dir eine Antwort geben zu wollen.

    Ich habe mir ImageSearch hier besorgt: https://www.autoitscript.com/forum/topic/65…library/?page=4
    Genauer gesagt dieses Archiv: https://www.autoitscript.com/forum/applicat…nt.php?id=28562

    Nach dem Entpacken des Archivs (z. B. nach @DesktopDir & "\ImageSearch\") musste ich die ImageSearchDemo.au3 kurz mit Tidy formatieren (Strg + T in SciTE drücken), weil sie sonst mit einer Fehlermeldung abbricht.

    Folgende Dateien habe ich dann aus diesem neu erstellten Verzeichnis auf den Desktop kopiert:
    folder.bmp
    ie7Desktop.bmp
    pdf.bmp
    recycle.bmp
    recycle2.bmp

    Dann anschließend einfach die Demo starten und schauen was passiert... bei mir hat alles funktioniert.

  • DLL registrieren mit Rückgabewert

    • Bitnugger
    • 4. Februar 2017 um 00:11

    Evtl. geht es ja so...

    DllReg
    AutoIt
    ;-- TIME_STAMP   2017-02-04 00:08:07
    
    
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseX64=n
    #AutoIt3Wrapper_Change2CUI=y
    #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    
    
    #RequireAdmin
    
    
    #include <WinAPIReg.au3>
    
    
    If $CMDLINE[0] <> 2 Then _Usage()
    
    
    FileChangeDir(@SystemDir)
    
    
    Global $iRes, $sRes
    Switch $CMDLINE[1]
    	Case '-u'
    		$iRes = _WinAPI_DllUninstall(StringFormat('"%s"', $CMDLINE[2]))
    		$sRes = ($iRes = 1) ? 'unregister successful!' : 'unregister failed!'
    	Case '-i'
    		$iRes = _WinAPI_DllInstall(StringFormat('"%s"', $CMDLINE[2]))
    		$sRes = ($iRes = 1) ? 'registration successful!' : 'registration failed!'
    	Case Else
    		_Usage($CMDLINERAW & ' - Wrong parameters!')
    EndSwitch
    
    
    ConsoleWrite(StringFormat('"%s" - %s', $CMDLINE[2], $sRes) & @CRLF)
    Exit
    
    
    Func _Usage($sMsg = '')
    	If $sMsg <> '' Then ConsoleWrite($sMsg & @CRLF & @CRLF)
    
    
    	ConsoleWrite(@ScriptName & ' -u|-i $sFilePath' & @CRLF)
    	ConsoleWrite(@ScriptName & ' -u "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll"' & @CRLF)
    	ConsoleWrite(@ScriptName & ' -i "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll"' & @CRLF)
    	Exit 1
    EndFunc
    Alles anzeigen
  • Senden von Escape-Sequenzen an Drucker (ESC/POS)

    • Bitnugger
    • 3. Februar 2017 um 11:30

    Evtl. hilft dir dies hier weiter: Drucker per Kommandozeile (CMD) verwalten – rundll32.exe printui.dll

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™