WatchDirectory()

Author: HotKeyIt, SKAN, Lexikos Last Modified: 20090613


- You can add a new folder to watch for.
- Report changes to any function
- Stop watching

WatchDirectory("C:\Windows",1)

For more details of the functions's parameters and return value, please see it's source code.

Remarks

This functionality already exist in Crazy Scripting : FolderSpy v0.96 Synchronous (http://www.autohotkey.com/forum/viewtopic.php?t=22862).

Requires at least Windows 2000 or higher.

It is not strictly standard conform, because it a awaits a user defined function.

Also this lacks an external documentation. Look for that at head of source.

For update's details and remarks related to the functions, please see the AutoHotkey Forum: http://www.autohotkey.com/forum/viewtopic.php?t=45237

License

nonexistent

Example

; #Include WatchDirectory.ahk
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#Persistent

OnExit,Exit
WatchDirectory("C:\Windows",1)
SetTimer,WatchFolder,100
Return

WatchFolder:
    WatchDirectory("RegisterChanges")
Return

RegisterChanges(action,folder,file){
    static
    #1:="New File", #2:="Deleted", #3:="Modified", #4:="Renamed From", #5:="Renamed To"
    ToolTip % #%Action% "`n" folder . (SubStr(folder,0)="\" ? "" : "\") . file
}   

Exit:
    WatchDirectory()
ExitApp