Jump to content

Recommended Posts

  • 1 year later...
Posted (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:

  1. 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.au3Fetching info...

RDC_1.1.zipFetching info...

Edited by Mbee
Posted RDC_1.1.zip & example test script
  • 2 weeks later...
Posted
  On 11/12/2016 at 3:21 AM, argumentum said:

I did not see the problem in v1.0 <snip>

It's all there, v1.1 just doesn't seem to work

Expand  

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!

Posted
  On 11/21/2016 at 9:52 PM, Mbee said:

I apologize for any etiquette violations or unintended toe-stepping-on

Expand  

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.
autoit_scripter_blue_userbar.png

Posted
  On 11/22/2016 at 5:15 AM, argumentum said:

Have no time this week to truly test.

Expand  
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.
autoit_scripter_blue_userbar.png

  • 2 weeks later...
  • Moderators
Posted

faustf,

Have you downloaded the DLL file? And where is code you wrote to test? Help us to help you.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted

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

#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

 

 

Posted

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

#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 :)

 

Posted
  On 12/12/2016 at 9:28 PM, faustf said:

i run the script it  works perfect  but  put  my cpu at 100% usage

Expand  
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.
autoit_scripter_blue_userbar.png

Posted

hi @argumentum  i remove a msgbox   but i  have the same effect  work  but put  100% cpu load

#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

 

Posted

i tryed in this mode  and  i saw  only  69% percent of usage of cpu  , i think is correct  , you  confirme  that???

#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

 

Posted (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 by faustf
Posted

questions  i notice   if  in script 

#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

Posted

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 Gude
How to ask questions the smart way!

  Reveal hidden contents

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

Posted

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 

 

Posted

$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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...