Popular Post Yashied Posted January 25, 2015 Popular Post Share Posted January 25, 2015 (edited) LAST VERSION - 1.025-Jan-15This is my way to use the API ReadDirectoryChangesW in AutoIt. The problem is that to use this function will not work fully without creating thread. To solve this problem, I wrote the simple DLL that provides work with threads. As a result, the AutoIt script only receives and processes the appropriate data from thread. To evaluate all features of the library, please see the full example with GUI for monitoring directories. For more information, see description for each function within the library.The following are the main features of the RDC UDF library.Creating multiple threads (unlimited) for monitoring different directories.Support for hot (unsafe) unplugging of removable devices such as USB flash drive, etc.Support for network drives.Support for 32- and 64-bit processes (RDC.dll and RDC_x64.dll).Easy to use functions from the library.Full examples, including GUI.Available functions_RDC_CloseDll_RDC_Create_RDC_Delete_RDC_Destroy_RDC_EnumRDC_RDC_GetCount_RDC_GetData_RDC_GetDirectory_RDC_GetRDCInfo_RDC_OpenDll_RDC_ResumeRDC UDF Library v1.0 (x86 and x64)Previous downloads: 17RDC.zipExamplesSimple (Loop mode)expandcollapse popup#Include <APIConstants.au3> #Include <RDC.au3> Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) _RDC_OpenDll() If @Error Then ConsoleWrite('Error: _RDC_OpenDll() - ' & @Error & @CR) Exit EndIf Global $aDir[3], $ID[3], $aData For $i = 0 To 2 $aDir[$i] = @ScriptDir & '\~TEST' & ($i + 1) & '~' If Not FileExists($aDir[$i]) Then DirCreate($aDir[$i]) EndIf Next For $i = 0 To 2 $ID[$i] = _RDC_Create($aDir[$i], 1, BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME, $FILE_NOTIFY_CHANGE_SIZE)) If @Error Then ConsoleWrite('Error: _RDC_Create() - ' & @Error & ', ' & @Extended & @CR) Exit EndIf Next While 1 For $i = 0 To 2 If $ID[$i] = -1 Then ContinueLoop EndIf $aData = _RDC_GetData($ID[$i]) If @Error Then ConsoleWrite('Error: _RDC_GetData() - ' & @Error & ', ' & @Extended & ', ' & _RDC_GetDirectory($ID[$i]) & @CR) ; Delete thread to avoid receiving this error! _RDC_Delete($ID[$i]) $ID[$i] = -1 ContinueLoop EndIf For $j = 1 To $aData[0][0] ConsoleWrite($aData[$j][1] & ' - ' & _RDC_GetDirectory($ID[$i]) & '\' & $aData[$j][0] & @CR) Next Next Sleep(10) WEndSimple (Notification mode)expandcollapse popup#Include <APIConstants.au3> #Include <RDC.au3> Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) _RDC_OpenDll() If @Error Then ConsoleWrite('Error: _RDC_OpenDll() - ' & @Error & @CR) Exit EndIf Global $hWnd = GUICreate('') Global $aDir[3] For $i = 0 To 2 $aDir[$i] = @ScriptDir & '\~TEST' & ($i + 1) & '~' If Not FileExists($aDir[$i]) Then DirCreate($aDir[$i]) EndIf Next GUIRegisterMsg($WM_RDC, 'WM_RDC') For $i = 0 To 2 _RDC_Create($aDir[$i], 1, BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME, $FILE_NOTIFY_CHANGE_SIZE), 0, $hWnd) If @Error Then ConsoleWrite('Error: _RDC_Create() - ' & @Error & ', ' & @Extended & @CR) Exit EndIf Next While 1 Sleep(1000) WEnd Func WM_RDC($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $aData = _RDC_GetData($lParam) If @Error Then ; Do something because notifications will not come from this thread! ConsoleWrite('Error: _RDC_GetData() - ' & @Error & ', ' & @Extended & ', ' & _RDC_GetDirectory($lParam) & @CR) _RDC_Delete($lParam) Return 0 EndIf For $i = 1 To $aData[0][0] ConsoleWrite($aData[$i][1] & ' - ' & _RDC_GetDirectory($lParam) & '\' & $aData[$i][0] & @CR) Next Return 0 EndFunc ;==>WM_RDCAdvancedexpandcollapse popup#Include <APIConstants.au3> #Include <RDC.au3> Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) Global Const $sDir = @ScriptDir & '\~TEST~' _RDC_OpenDll() If @Error Then ConsoleWrite('Error: _RDC_OpenDll() - ' & @Error & @CR) Exit EndIf Global $hWnd = GUICreate('') Global $sEvents = '' If Not FileExists($sDir) Then DirCreate($sDir) EndIf GUIRegisterMsg($WM_RDC, 'WM_RDC') _RDC_Create($sDir, 1, BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME, $FILE_NOTIFY_CHANGE_SIZE), 0, $hWnd) If @Error Then ConsoleWrite('Error: _RDC_Create() - ' & @Error & ', ' & @Extended & @CR) Exit EndIf While 1 Sleep(1000) WEnd Func _IsDirectory($sPath) If StringInStr(FileGetAttrib($sPath), 'D') Then Return 1 Else Return 0 EndIf EndFunc ;==>_IsDirectory Func _RetrieveDirectoryChanges() AdlibUnRegister('_RetrieveDirectoryChanges') Local $aData, $aText, $aPrev[2] = [0, ''], $sPrev = '' $aData = StringSplit($sEvents, '|', 2) $sEvents = '' If Not IsArray($aData) Then Return EndIf For $i = 0 To UBound($aData) If $i < UBound($aData) Then If $aData[$i] = $sPrev Then ContinueLoop EndIf $sPrev = $aData[$i] $aText = StringSplit($aData[$i], '?', 2) If IsArray($aText) Then ;~ ConsoleWrite($aText[0] & ' - ' & $aText[1] & @CR) ;~ ContinueLoop Switch Number($aText[0]) Case 1 ; FILE_ACTION_ADDED Switch Number($aPrev[0]) Case 2 If StringRegExpReplace($aPrev[1], '^.*\\', '') = StringRegExpReplace($aText[1], '^.*\\', '') Then If $aPrev[1] = $aText[1] Then ;~ If _IsDirectory($aText[1]) Then ;~ ; Nothing ;~ Else ;~ ; Nothing ;~ EndIf $aPrev[0] = 0 ContinueLoop Else If _IsDirectory($aText[1]) Then ConsoleWrite('DIRECTORY MOVED: ' & $aPrev[1] & ' ---> ' & $aText[1] & @CR) Else ConsoleWrite('FILE MOVED: ' & $aPrev[1] & ' ---> ' & $aText[1] & @CR) EndIf $aPrev[0] = 0 ContinueLoop EndIf EndIf EndSwitch Case 2 ; FILE_ACTION_REMOVED ; Nothing Case 3 ; FILE_ACTION_MODIFIED Switch Number($aPrev[0]) Case 1 ;~ If True Then If $aPrev[1] = $aText[1] Then If _IsDirectory($aText[1]) Then ; Nothing Else ConsoleWrite('FILE ADDED: ' & $aText[1] & @CR) EndIf $aPrev[0] = 0 ContinueLoop EndIf ;~ EndIf Case 2 If StringRegExpReplace($aPrev[1], '^.*\\', '') = StringRegExpReplace($aText[1], '^.*\\', '') Then ;~ If True Then If _IsDirectory($aText[1]) Then ; Nothing Else ConsoleWrite('FILE DELETED: ' & $aText[1] & @CR) ConsoleWrite('FILE MOVED: ' & $aPrev[1] & ' ---> ' & $aText[1] & @CR) EndIf $aPrev[0] = 0 ContinueLoop ;~ EndIf EndIf EndSwitch Case 4 ; FILE_ACTION_RENAMED_OLD_NAME ; Nothing Case 5 ; FILE_ACTION_RENAMED_NEW_NAME Switch Number($aPrev[0]) Case 4 If StringRegExpReplace($aPrev[1], '\\[^\\]*\Z', '') = StringRegExpReplace($aText[1], '\\[^\\]*\Z', '') Then ;~ If True Then If _IsDirectory($aText[1]) Then ConsoleWrite('DIRECTORY RENAMED: ' & $aPrev[1] & ' ---> ' & $aText[1] & @CR) Else ConsoleWrite('FILE RENAMED: ' & $aPrev[1] & ' ---> ' & $aText[1] & @CR) EndIf $aPrev[0] = 0 ContinueLoop ;~ EndIf EndIf EndSwitch EndSwitch EndIf EndIf Switch Number($aPrev[0]) Case 1 ; FILE_ACTION_ADDED If _IsDirectory($aPrev[1]) Then ConsoleWrite('DIRECTORY ADDED: ' & $aPrev[1] & @CR) Else ConsoleWrite('FILE ADDED: ' & $aPrev[1] & @CR) EndIf Case 2 ; FILE_ACTION_REMOVED ;~ If True Then ConsoleWrite('FILE OR DIRECTORY DELETED: ' & $aPrev[1] & @CR) ;~ EndIf Case 3 ; FILE_ACTION_MODIFIED If _IsDirectory($aPrev[1]) Then ; Nothing Else ConsoleWrite('FILE MODIFIED: ' & $aPrev[1] & @CR) EndIf EndSwitch $aPrev = $aText Next ConsoleWrite('---------------------------------------------' & @CR) EndFunc ;==>_RetrieveDirectoryChanges Func WM_RDC($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $aData = _RDC_GetData($lParam) If @Error Then ; Do something because notifications will not come from this thread! ConsoleWrite('Error: _RDC_GetData() - ' & @Error & ', ' & @Extended & ', ' & _RDC_GetDirectory($lParam) & @CR) _RDC_Delete($lParam) Return 0 EndIf For $i = 1 To $aData[0][0] If $sEvents Then $sEvents &= '|' EndIf $sEvents &= $aData[$i][1] & '?' & _RDC_GetDirectory($lParam) & '\' & $aData[$i][0] Next AdlibRegister('_RetrieveDirectoryChanges', 250) Return 0 EndFunc ;==>WM_RDCGUISee GUI.zip from attached archive. Edited January 25, 2015 by Yashied TheDcoder, argumentum, Loz and 5 others 6 2 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Geir1983 Posted January 26, 2015 Share Posted January 26, 2015 This is pretty cool. Is it possible somehow to create a cached comparison? I want to monitor a network drive for changes, but the script will not be running 24/7. Link to comment Share on other sites More sharing options...
Mbee Posted November 5, 2016 Share Posted November 5, 2016 (edited) I found and repaired a tiny problem with RDC.au3 and have attached a zip file with the correction (all other files are exactly as provided by @Yashied 's great UDF). This is the one small problem I corrected: The UDF function _RDC_GetData() originally did not return the output data array in the order the documentation specified; i.e., element "[n][0]" used to hold the filename and "[n][1]" used to return the change type. Now the function returns the data as specified. This was a trivial correction and should not detract from Yasheid's fine code and extremely useful UDF.  By the way, to those who haven't used this and similar UDFs that make use of Microsoft's "ReadDirectoryChangesW" function, please be aware that you will see duplicate notifications of most (or all?) changes. For example, if a new file is created in a directory being watched, you will see two identical FILE_ACTION_ADDED notifications, both with the same filename...  General RDC v1.1 Test Script with GUI.au3 RDC_1.1.zip Edited December 17, 2016 by Mbee Posted RDC_1.1.zip & example test script Link to comment Share on other sites More sharing options...
argumentum Posted November 12, 2016 Share Posted November 12, 2016 (edited) On 11/5/2016 at 3:24 PM, Mbee said: I found and repaired a tiny problem I did not see the problem in v1.0 <snip> It's all there, v1.1 just doesn't seem to work Edited November 12, 2016 by argumentum revised again Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
nend Posted November 12, 2016 Share Posted November 12, 2016 Nice I haven't see this UDF before, I think I will have use for in the future. Thanks for sharing. Link to comment Share on other sites More sharing options...
Mbee Posted November 21, 2016 Share Posted November 21, 2016 On 11/11/2016 at 10:21 PM, argumentum said: I did not see the problem in v1.0 <snip> It's all there, v1.1 just doesn't seem to work Please forgive the delay in responding... I apologize for any etiquette violations or unintended toe-stepping-on, good sir! But I'd like more information concerning your reply, if you'd be so kind. Are you saying that version 1.0 DID return the type in [n][0] and the filename in [n][1], or what? Because v1.0 definitely returned them in the order opposite to what the documentation said when I used it. v1.1 returns [n][0] = type, [n][1] = filename, as documented. Please let me know precisely what you mean when you say "v1.1 just doesn't seem to work". Thanks! Link to comment Share on other sites More sharing options...
argumentum Posted November 22, 2016 Share Posted November 22, 2016 7 hours ago, Mbee said: I apologize for any etiquette violations or unintended toe-stepping-on no toes here. The code you posted, I've tried then, and did not work at the time. Not my code, no pride, even if it was my code, just a technical view. Have no time this week to truly test. I'll give it a better try later and compare the results. I may have to write a script that writes very fast and see what you mean. I use mailslots as an IPC to not slow down this code, so I get the results in another script reading the mailsot. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted November 27, 2016 Share Posted November 27, 2016 On 11/22/2016 at 0:15 AM, argumentum said: Have no time this week to truly test. Local $n Local $t = @MIN&@SEC For $n = 1 To 100 ;~ Sleep($n * 10) FileWriteLine(@ScriptDir&'\~TEST~\testFastWrite'&$t&'_'&$n&'.txt',"delete, this just a test."&@CRLF) Next @Mbee , I've runned this and checked the original code's result. Could not find anything out of sequence. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
faustf Posted December 12, 2016 Share Posted December 12, 2016 hi i have a questions about RDC 1.1  https://www.autoitscript.com/forum/applications/core/interface/file/attachment.php?id=52633 i tryed to run a example file RDC_Ex_Simple (Notification).au3  but where is a path for monitoring a file/folder?? i used also a GUI , i choice a folder , and after create and modify and remove a file txt , inside the folder , but not appear nothing in gui o_O Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 12, 2016 Moderators Share Posted December 12, 2016 faustf, Have you downloaded the DLL file? And where is code you wrote to test? Help us to help you. M23  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...
faustf Posted December 12, 2016 Share Posted December 12, 2016 o thankz so much @Melba23 at end i think i have understund somthing i modify a example script like this and i saw the script work , more or less for my case expandcollapse popup#Include <APIConstants.au3> #Include <RDC.au3> Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) _RDC_OpenDll() If @Error Then ConsoleWrite('Error: _RDC_OpenDll() - ' & @Error & @CR) Exit EndIf Global $hWnd = GUICreate('') Global $aDir[3] For $i = 0 To 2 $aDir[$i] = @ScriptDir & '\~TEST' & ($i + 1) & '~' If Not FileExists($aDir[$i]) Then DirCreate($aDir[$i]) EndIf Next GUIRegisterMsg($WM_RDC, 'WM_RDC') For $i = 0 To 2 _RDC_Create("C:\Users\utente\Desktop\", 1, BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME, $FILE_NOTIFY_CHANGE_SIZE), 0, $hWnd) If @Error Then ConsoleWrite('Error: _RDC_Create() - ' & @Error & ', ' & @Extended & @CR) Exit EndIf Next While 1 Sleep(1000) WEnd Func WM_RDC($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $aData = _RDC_GetData($lParam) If @Error Then ; Do something because notifications will not come from this thread! ConsoleWrite('Error: _RDC_GetData() - ' & @Error & ', ' & @Extended & ', ' & _RDC_GetDirectory($lParam) & @CR) _RDC_Delete($lParam) Return 0 EndIf For $i = 1 To $aData[0][0] ConsoleWrite($aData[$i][1] & ' - ' & _RDC_GetDirectory($lParam) & '\' & $aData[$i][0] & @CR) Next Return 0 EndFunc ;==>WM_RDC   Link to comment Share on other sites More sharing options...
faustf Posted December 12, 2016 Share Posted December 12, 2016 hi guys i did do a little modify , for understund how work the script RDC_EX_Simple.au3 but i have a problem , i run the script it works perfect but put my cpu at 100% usage , probably i did do some error expandcollapse popup#Include <APIConstants.au3> #Include <RDC.au3> Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) _RDC_OpenDll() If @Error Then ConsoleWrite('Error: _RDC_OpenDll() - ' & @Error & @CR) Exit EndIf Global $hWnd = GUICreate('') Global $aDir[3] For $i = 0 To 2 $aDir[$i] = @ScriptDir & '\~TEST' & ($i + 1) & '~' If Not FileExists($aDir[$i]) Then DirCreate($aDir[$i]) EndIf Next GUIRegisterMsg($WM_RDC, 'WM_RDC') For $i = 0 To 2 _RDC_Create("C:\Users\utente\Desktop", 1, BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME, $FILE_NOTIFY_CHANGE_SIZE), 0, $hWnd) If @Error Then ConsoleWrite('Error: _RDC_Create() - ' & @Error & ', ' & @Extended & @CR) Exit EndIf Next While 1 Sleep(1000) WEnd Func WM_RDC($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $aData = _RDC_GetData($lParam) If @Error Then ; Do something because notifications will not come from this thread! ConsoleWrite('Error: _RDC_GetData() - ' & @Error & ', ' & @Extended & ', ' & _RDC_GetDirectory($lParam) & @CR) _RDC_Delete($lParam) Return 0 EndIf For $i = 1 To $aData[0][0] ConsoleWrite($aData[$i][1] & ' - ' & _RDC_GetDirectory($lParam) & '\' & $aData[$i][0] & @CR) Select Case $aData[$i][0] = 1 ; è crea file ; se è passatoda qui non deve attiva il punto 3 MsgBox(0,'Info','Lancio controllo formato') ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) Case $aData[$i][0] = 2 ; è cancella file MsgBox(0,'Info','Lancio ftpbox') ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) Case $aData[$i][0] = 3 ; è modifica file MsgBox(0,'Info','Lancio controllo formato modifica file') ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) EndSelect ; ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) Next Return 0 EndFunc ;==>WM_RDC someone can help me?? thankz again  Link to comment Share on other sites More sharing options...
argumentum Posted December 13, 2016 Share Posted December 13, 2016 7 hours ago, faustf said: i run the script it works perfect but put my cpu at 100% usage MsgBox(0,'Info','Lancio controllo formato') is a blocking thing. Do not use msgbox in this script. Anything that is called by GUIRegisterMsg should not be slow. Make a global variable that changes to, lets say, to 1, then from the main loop you can do the MsgBox or what not. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
faustf Posted December 13, 2016 Share Posted December 13, 2016 hi @argumentum i remove a msgbox  but i have the same effect work but put 100% cpu load expandcollapse popup#Include <APIConstants.au3> #include <GDIPlus.au3> #Include <RDC.au3> Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) _RDC_OpenDll() If @Error Then ConsoleWrite('Error: _RDC_OpenDll() - ' & @Error & @CR) Exit EndIf Global $hWnd = GUICreate('') Global $aDir[3] For $i = 0 To 2 $aDir[$i] = @ScriptDir & '\~TEST' & ($i + 1) & '~' If Not FileExists($aDir[$i]) Then DirCreate($aDir[$i]) EndIf Next GUIRegisterMsg($WM_RDC, 'WM_RDC') For $i = 0 To 2 _RDC_Create("C:\Users\utente\Desktop", 1, BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME, $FILE_NOTIFY_CHANGE_SIZE), 0, $hWnd) If @Error Then ConsoleWrite('Error: _RDC_Create() - ' & @Error & ', ' & @Extended & @CR) Exit EndIf Next While 1 Sleep(1000) WEnd Func WM_RDC($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $aData = _RDC_GetData($lParam) If @Error Then ; Do something because notifications will not come from this thread! ConsoleWrite('Error: _RDC_GetData() - ' & @Error & ', ' & @Extended & ', ' & _RDC_GetDirectory($lParam) & @CR) _RDC_Delete($lParam) Return 0 EndIf For $i = 1 To $aData[0][0] ConsoleWrite($aData[$i][1] & ' - ' & _RDC_GetDirectory($lParam) & '\' & $aData[$i][0] & @CR) Select Case $aData[$i][0] = 1 ; è crea file ; se è passatoda qui non deve attiva il punto 3 ;MsgBox(0,'Info','Lancio controllo formato') ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) Case $aData[$i][0] = 2 ; è cancella file ;MsgBox(0,'Info','Lancio ftpbox') ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) Case $aData[$i][0] = 3 ; è modifica file ;MsgBox(0,'Info','Lancio controllo formato modifica file') ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) EndSelect Sleep(100) ; ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) Next Return 0 EndFunc ;==>WM_RDC  Link to comment Share on other sites More sharing options...
faustf Posted December 13, 2016 Share Posted December 13, 2016 i tryed in this mode and i saw only 69% percent of usage of cpu , i think is correct , you confirme that??? expandcollapse popup#Include <APIConstants.au3> #include <GDIPlus.au3> #Include <RDC.au3> Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) _RDC_OpenDll() If @Error Then ConsoleWrite('Error: _RDC_OpenDll() - ' & @Error & @CR) Exit EndIf Global $hWnd = GUICreate('') Global $aDir[3] Global $iGResult For $i = 0 To 2 $aDir[$i] = @ScriptDir & '\~TEST' & ($i + 1) & '~' If Not FileExists($aDir[$i]) Then DirCreate($aDir[$i]) EndIf Next GUIRegisterMsg($WM_RDC, 'WM_RDC') For $i = 0 To 2 _RDC_Create("C:\Users\utente\Desktop", 1, BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME, $FILE_NOTIFY_CHANGE_SIZE), 0, $hWnd) If @Error Then ConsoleWrite('Error: _RDC_Create() - ' & @Error & ', ' & @Extended & @CR) Exit EndIf Next While 1 Sleep(1000) WEnd Func WM_RDC($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $aData = _RDC_GetData($lParam) If @Error Then ; Do something because notifications will not come from this thread! ConsoleWrite('Error: _RDC_GetData() - ' & @Error & ', ' & @Extended & ', ' & _RDC_GetDirectory($lParam) & @CR) _RDC_Delete($lParam) Return 0 EndIf For $i = 1 To $aData[0][0] ConsoleWrite($aData[$i][1] & ' - ' & _RDC_GetDirectory($lParam) & '\' & $aData[$i][0] & @CR) $iGResult=$aData[$i][0] #cs Select Case $aData[$i][0] = 1 ; è crea file ; se è passatoda qui non deve attiva il punto 3 ;MsgBox(0,'Info','Lancio controllo formato') ;ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) Case $aData[$i][0] = 2 ; è cancella file ;MsgBox(0,'Info','Lancio ftpbox') ; ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) Case $aData[$i][0] = 3 ; è modifica file ;MsgBox(0,'Info','Lancio controllo formato modifica file') ;ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) EndSelect #ce ; ConsoleWrite(_RDC_GetDirectory($lParam) & '\' &$aData[$i][1] & @CR) Next ConsoleWrite($iGResult) Return 0 EndFunc ;==>WM_RDC  Link to comment Share on other sites More sharing options...
faustf Posted December 13, 2016 Share Posted December 13, 2016 (edited) hi  where is a list of error , my prog return this  error Error: _RDC_GetData() - 5, 0, 0 Error: _RDC_GetData() - 7, 1, E:\_GESTIONALE_NEW\WEB-SITE\eBay\PUBLICAZIONI\FOTO\ sorry i not saw , i answer me   Error codes:        @Error:        0 - No error        1 - DLL not loaded or already loaded        2 - DLL not found        3 - Incompatible DLL version        4 - Unable to load DLL        5 - Invalid parameter(s)        6 - Directory not found        7 - DllCall() error Edited December 13, 2016 by faustf Link to comment Share on other sites More sharing options...
faustf Posted December 13, 2016 Share Posted December 13, 2016 questions i notice  if in script expandcollapse popup#include <APIConstants.au3> #include <GDIPlus.au3> #include "RDC.au3" Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) _RDC_OpenDll() If @error Then ConsoleWrite('Error: _RDC_OpenDll() - ' & @error & @CR) Exit EndIf Global $hWnd = GUICreate('') Global $aDir[3] Global $iGResult For $i = 0 To 2 $aDir[$i] = @ScriptDir & '\TEMP\~TEST' & ($i + 1) & '~' If Not FileExists($aDir[$i]) Then DirCreate($aDir[$i]) EndIf Next GUIRegisterMsg($WM_RDC, 'WM_RDC') For $i = 0 To 2 _RDC_Create("C:\Users\utente\Desktop", 1, BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME, $FILE_NOTIFY_CHANGE_SIZE), 0, $hWnd) If @error Then ConsoleWrite('Error: _RDC_Create() - ' & @error & ', ' & @extended & @CR) Exit EndIf Next While 1 Sleep(1000) WEnd Func WM_RDC($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $aData = _RDC_GetData($lParam) If @error Then ; Do something because notifications will not come from this thread! ConsoleWrite('Error: _RDC_GetData() - ' & @error & ', ' & @extended & ', ' & _RDC_GetDirectory($lParam) & @CR) _RDC_Delete($lParam) Return 0 EndIf For $i = 1 To $aData[0][0] $iGResult = $aData[$i][0] Next ConsoleWrite($iGResult) Return 0 EndFunc ;==>WM_RDC i use C:\Users\utente\Desktop work good but if i use attached hdd network(E:\_GESTIONALE_NEW\WEB-SITE\) , not work and give me error 5 , how is possible change them??? thankz Link to comment Share on other sites More sharing options...
BrewManNH Posted December 13, 2016 Share Posted December 13, 2016 This script works for me with a network drive. But there a numerous errors with it. You don't need the For loops in your script, and you don't even need the entire contents of the first For loop at all. Second, it looks like you smashed the 2 example scripts together without understanding what each one is to be used for, and missing parts of each that might make the issue you're having happen.   If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
faustf Posted December 14, 2016 Share Posted December 14, 2016 questions , i try to understund how work the script , why  RDC.au3 , i have this value?? Global Const $WM_RDC = 0xA000 why 0xA000 and not another value??? thankz  Link to comment Share on other sites More sharing options...
LarsJ Posted December 15, 2016 Share Posted December 15, 2016 $WM_RDC = 0xA000 is a user defined message code in the range 0x8000 through 0xBFFF which are available for applications to use as private messages. See WM_USER. 0xA000 is (except that it is easy to remember) a random number in this range. argumentum 1 Controls,  File Explorer,  ROT objects,  UI Automation,  Windows Message MonitorCompiled code: Accessing AutoIt variables,  DotNet.au3 UDF,  Using C# and VB codeShell menus: The Context menu,  The Favorites menu. Shell related: Control Panel,  System Image ListsGraphics related: Rubik's Cube,  OpenGL without external libraries,  Navigating in an image,  Non-rectangular selectionsListView controls: Colors and fonts,  Multi-line header,  Multi-line items,  Checkboxes and icons,  Incremental searchListView controls: Virtual ListViews,  Editing cells,  Data display functions 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