ericire Posted April 17, 2019 Share Posted April 17, 2019 Hello,I need to monitor events regarding multiple folders and files.For example, the arrival of a file in the google drive sync on the hard disk or changes made to files or other folders.I tested Rmonitor which works well to monitor a single folder but in the case of google drive sync, it stops at changes made in the temporary folder used by google, and therefore does not capture the arrival of the file in the folder of destination.Is Rmonitor configurable to capture all the changes (I did not understand the interest of the loops while 1 in the example), or do you have to multiply Rmonitor for each watched folder?Or is there another way to capture these changes on several specific folders and files? Rmonitor thread https://www.autoitscript.fr/forum/viewtopic.php?p=78100#p78100 Rmonitor file https://www.autoitscript.fr/forum/download/file.php?id=3245 example #include "RepMonitor.au3" ; Configuration: ; On va surveiller mon bureau... RMonitor_SetFolder("C:\Users\Jon\Desktop\") ; ...en appelant _TestCalback à chaque évènement RMonitor_SetCallback("_TestCallback") ; ### EXEMPLE 1: Attente d'un évènement ### While 1 ; La boucle est interrompue à chaque attente RMonitor_WaitForEvents() WEnd ; ### EXEMPLE 2: Surveillance continue ### RMonitor_StartMonitoring() While 1 ; La boucle est continue WEnd RMonitor_StopMonitoring() ; Notre callback favorite: ; Un seul argument de type wstr ; Prototype C: ; void _TestCallback(const wchar_t MSG); ; void _TestCallback(LPCWSTR MSG); (en WINAPI) Func _TestCallback($MSG) ; 1er caractère = ID de l'évènement Local $EventID = StringLeft($MSG, 1), _ $CompletePath = "C:\Users\Jon\" & StringTrimLeft($MSG, 1) ; Reste = Chemin RELATIF du dossier|fichier Static $OldName Switch ($EventID) Case $FILE_ACTION_ADDED ConsoleWrite("Ajout: " & $CompletePath & @CRLF) Case $FILE_ACTION_REMOVED ConsoleWrite("Suppression: " & $CompletePath & @CRLF) Case $FILE_ACTION_MODIFIED ConsoleWrite("Modification: " & $CompletePath & @CRLF) Case $FILE_ACTION_RENAMED_OLD_NAME $OldName = $CompletePath Case $FILE_ACTION_RENAMED_NEW_NAME ConsoleWrite("Renommé: " & $OldName & " en " & $CompletePath & @CRLF) EndSwitch EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 17, 2019 Moderators Share Posted April 17, 2019 Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nend Posted April 17, 2019 Share Posted April 17, 2019 Do you mean this? Link to comment Share on other sites More sharing options...
orbs Posted April 17, 2019 Share Posted April 17, 2019 no matter how you look at it, ReadDirectoryChangesW supports a single root path per thread - meaning, it can monitor only a single folder and its subfolders per thread. since AutoIt is not multithreaded, that limitation becomes process-dependent, rather than thread-dependent - meaning, one process can monitor only a single folder and its subfolders. the help file example for _WinAPI_ReadDirectoryChanges() is a perfectly workable script for a single folder, so if you rely on AutoIt alone, you need to run that script multiple times for multiple folders. a workaround is of course as suggested above, using an external DLL. SkysLastChance 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Nine Posted April 17, 2019 Share Posted April 17, 2019 Like orbs implies you will need multiple processes to monitor multiple folders using _WinAPI_ReadDirectoryChanges(). But it would be kind of easy to create a single monitor script (parent) that would launch multiple _WinAPI_ReadDirectoryChanges() processes (childs) and grab the results reading at StdoutRead (). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
ericire Posted April 17, 2019 Author Share Posted April 17, 2019 thanks for this waysI am studying the RDC example which obviously refers to a mother file that can monitor several folders Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now