WatchFolder.ahk question
Posted: 30 Apr 2024, 17:22
I'm using WatchFolder.ahk from viewtopic.php?f=6&t=8384
I want to watch below actions for 2 predefined paths:
Once any of the above action are detected, run AutoHotkeySyncTest function.
My code wasn't able to detect any of the actions, and I think the problem is this function "AutoHotkeySyncTest()" where I need to pass in some arguments? It should be something like this example below:
But I'm don't understand this example code provided from WatchFolder_sample.ahk and how I can integrate that into my function.
Any advice would be greatly appreciated, thanks!
I want to watch below actions for 2 predefined paths:
Code: Select all
; FILE_ACTION_ADDED = 1 (0x00000001) : The file was added to the directory.
; FILE_ACTION_REMOVED = 2 (0x00000002) : The file was removed from the directory.
; FILE_ACTION_MODIFIED = 3 (0x00000003) : The file was modified.
; FILE_ACTION_RENAMED = 4 (0x00000004) : The file was renamed (not defined by Microsoft).
Code: Select all
AutoHotkeySyncPath1 := "C:\Users\Cody\Desktop\New folder\Ahk"
AutoHotkeySyncPath2 := "C:\Users\Cody\Desktop\New folder\Ahk2"
AutoHotkeySyncTest() {
FolderSync(AutoHotkeySyncPath1, AutoHotkeySyncPath2)
}
FolderSync(Path1, Path2) {
Run, %ComSpec% /c robocopy "%Path1%" "%Path2%" /MIR",, Hide
}
WatchFolder(AutoHotkeySyncPath1, "AutoHotkeySyncTest", True, 1|2|3|4)
WatchFolder(AutoHotkeySyncPath2, "AutoHotkeySyncTest", True, 1|2|3|4)
Code: Select all
MyUserFunc(Folder, Changes) {
Static Actions := ["1 (added)", "2 (removed)", "3 (modified)", "4 (renamed)"]
TickCount := A_TickCount
GuiControl, -ReDraw, LV
For Each, Change In Changes
LV_Modify(LV_Add("", TickCount, Folder, Actions[Change.Action], Change.Name, Change.IsDir, Change.OldName, ""), "Vis")
Loop, % LV_GetCount("Columns")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +Redraw, LV
}
Any advice would be greatly appreciated, thanks!