Vielleicht kannst du ja hiermit etwas anfangen...
_MonitorDirectory-Demo
AutoIt
;-- TIME_STAMP 2016-09-14 14:49:59
#Region ;************ Includes ************
#include <WindowsConstants.au3>
#include <Array.au3>
;~ #include <GUIConstants.au3>;~~~
#include <GUIConstantsEx.au3>
#include <MonitorDirectory.au3>
;~ #include <WindowsConstants.au3>;~~~
#EndRegion ;************ Includes ************
Global $g_aDirs = ['f:\_Scripts\AutoIt\AutoIt3_MyInclude\', 'f:\Eigene Dateien\Pictures\']
;_ArrayDisplay($g_aDirs, '$g_aDirs')
;~ =========================== FUNCTION _MonitorDirectory() ==============================
#cs
Description: Monitors the user defined directories for file activity.
Original: http://www.autoitscript.com/forum/index.php?showtopic=69044&hl=folderspy&st=0
Modified: Jack Chen
Syntax: _MonitorDirectory($Dirs = "", $Subtree = True, $TimerMs = 250, $Function = "_ReportChanges")
Parameters:
$Dirs - Optional: Zero-based array of valid directories to be monitored.
$Subtree - Optional: Subtrees will be monitored if $Subtree = True.
$TimerMs - Optional: Timer to register changes in milliseconds.
$Function - Optional: Function to launch when changes are registered. e.g. _ReportChanges
Syntax of your function must be e.g._ReportChanges($Action, $FilePath)
Possible actions: Created, Deleted, Modified, Rename-, Rename+, Unknown
Remarks: Call _MonitorDirectory() without parameters to stop monitoring all directories.
THIS SHOULD BE DONE BEFORE EXITING SCRIPT AT LEAST.
#ce
#Region - GUI Create
Global $g_hGUI = GUICreate('_MonitorDirectory-Demo', 600, 430, -800)
Global $g_idButton_Start = GUICtrlCreateButton('Start', 2, 402, 296)
Global $g_idButton_Exit = GUICtrlCreateButton('Exit', 302, 402, 296)
Global $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
GUISetState()
#EndRegion - GUI Create
#Region - GUI SelectLoop
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $g_idButton_Exit
_MonitorDirectory()
Exit
Case $g_idButton_Start
_MonitorDirectory($g_aDirs, True, 250, '__ReportChanges')
If @error Then Exit 99
MemoWrite('##################### Folgene Verzeichnisse werden überwacht ####################')
MemoWrite(_ArrayToString($g_aDirs, @CRLF))
MemoWrite('#################################################################################')
;Case $msg =
EndSwitch
WEnd
#EndRegion - GUI SelectLoop
Func __ReportChanges($Action, $FilePath)
Local Static $sAktFilePath = ""
Local $sColor = "", $aPos
;~ Your own script here ...
;~ ...
If $sAktFilePath = "" Then
$sAktFilePath = $FilePath
Else
If $sAktFilePath <> $FilePath Then
$sAktFilePath = $FilePath
ConsoleWrite(@LF)
EndIf
EndIf
$aPos = MouseGetPos()
Switch $Action
Case "Created"
$sColor = "+"
Case "Deleted"
$sColor = "!"
Case "Modified"
$sColor = "-"
Case "Rename-"
$sColor = ">"
Case "Rename+"
$sColor = ">"
Case "Unknown"
$sColor = ""
EndSwitch
; ConsoleWrite($sColor & StringFormat("%-9s%-5s%-256s", $Action, "-->", $FilePath) & @CRLF)
MemoWrite(StringFormat('%s %s: %s %s %s', "MonitorDirectory", $Action, $FilePath, $aPos[0] + 10, $aPos[1] + 10))
EndFunc ;==>__ReportChanges
; Write a line to the memo control
Func MemoWrite($sMessage = '')
GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite
Alles anzeigen