carloselectro Posted May 3, 2017 Share Posted May 3, 2017 Hi, I'm trying to check continuously if an application is writing to a specific folder. I was thinking of doing it like the example below but I have to manually refresh the folder in windows otherwise Autoit will always get the same folder size. The application is recording videos in MP4. If there is a fast way of checking if the application is recording a file I'm willing to change my code. $Record_Folder = "C:\Videos\" While (1) $foldersize_1 = DirGetSize($Record_Folder) ConsoleWrite("Folder size now : " & $foldersize_1 & @CRLF) Sleep(2000) $foldersize_2 = DirGetSize($Record_Folder) ConsoleWrite("Foldersize after 2 seconds : " & $foldersize_2 & @CRLF) WEnd Link to comment Share on other sites More sharing options...
jguinch Posted May 4, 2017 Share Posted May 4, 2017 There are several UDF for that. Search for SHChangeNotifyRegister Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
carloselectro Posted May 4, 2017 Author Share Posted May 4, 2017 It's a nice UDF, but it's not working for live video recording. I still have to refresh the folder to see the changes detected. It's working with regular files though (ie writing to a text file). I did my tests with this: FileSystemMonitor UDF https://www.autoitscript.com/forum/topic/148327-filesystemmonitor-udf-partially-broken-in-x64-environment-autoit-v3381/ Link to comment Share on other sites More sharing options...
argumentum Posted May 4, 2017 Share Posted May 4, 2017 57 minutes ago, carloselectro said: It's a nice UDF, but it's not working for live video recording _WinAPI_ReadDirectoryChanges(), try that as is. Then play around. I use it with MailSlot UDF for IPC to another script that then works with the info. If you find it to be the solution, please post the results here. 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...
carloselectro Posted May 4, 2017 Author Share Posted May 4, 2017 Same problem, it detects a couple of writes when I start recording and stops detecting anything after 3 or 4 seconds. Here"s my code: #include <APIFilesConstants.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <WinAPIDiag.au3> #include <WinAPIFiles.au3> #include <WinAPISys.au3> Global $g_sPath = "C:\Videos" Local $hDirectory = _WinAPI_CreateFileEx($g_sPath, $OPEN_EXISTING, $FILE_LIST_DIRECTORY, BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE), $FILE_FLAG_BACKUP_SEMANTICS) If @error Then _WinAPI_ShowLastError('', 1) EndIf Local $pBuffer = _WinAPI_CreateBuffer(8388608) Local $aData While 1 $aData = _WinAPI_ReadDirectoryChanges($hDirectory, BitOR($FILE_NOTIFY_CHANGE_LAST_WRITE, $FILE_NOTIFY_CHANGE_SIZE,$FILE_NOTIFY_CHANGE_LAST_ACCESS), $pBuffer, 8388608, 0) If Not @error Then ConsoleWrite("Writting" & @CRLF) Else _WinAPI_ShowLastError('', 1) EndIf Sleep(200) WEnd Link to comment Share on other sites More sharing options...
argumentum Posted May 4, 2017 Share Posted May 4, 2017 (edited) 14 minutes ago, carloselectro said: Same problem, it detects a couple of writes when I start recording and stops detecting ok, ... the sleep is undesired, use a ToolTip(@sec&@MSEC) to see the event triggering. What is needed is the fastest return to be ready for the next event. Now, I've tried this code writing 40000 ( yes, 40 thousand ) files to a ram disk, at a rate of 2 files per millisecond and captured every event of addition and modification, so I know the code is fine. There is another issue here and that is that the file is opened by the application, streaming along and does not tell the OS, but I'm sure that once it's done writing, it closes the file and the OS picks it up and your code reflects the event, in this case, modified. The other thing you can do to try to determine if the drive is too full is to use DriveSpaceFree() or DriveSpaceTotal(). Try that, it may be a solution, for I believe the problem is drive space. Edited May 4, 2017 by argumentum 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...
carloselectro Posted May 4, 2017 Author Share Posted May 4, 2017 32 minutes ago, argumentum said: There is another issue here and that is that the file is opened by the application, streaming along and does not tell the OS, I bet it's the problem too. 33 minutes ago, argumentum said: The other thing you can do to try to determine if the drive is too full is to use DriveSpaceFree() or DriveSpaceTotal(). Try that, it may be a solution, for I believe the problem is drive space. The DriveSpaceFree() function seems to be working for what I need to do, I can now see disk space decreasing as opposed to The DirGetSize() function that would not work. Thanks a lot for your help argumentum 1 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