LizardLord Posted November 15, 2008 Share Posted November 15, 2008 I made a small script to keep track of my Temp file, but i never finished it and probably never will, so that's why i am releasing it now. The code is based almost entirely of functions, and some functions have parts of code that was going to be used, but never were. It works, but has numerous bugs/glitches. Especially when it comes to the Tool Tips... Maybe you guys will use it for something. I am still fairly new at Programming in General, so if i made any retarded mistakes don't bash my head in. expandcollapse popup#include <Array.au3> Opt("TrayMenuMode", 1) Dim $Array[1] Global $ErrorCode, $oDir $hExit = TrayCreateItem("Exit") $hDir = TrayCreateItem("Choose Folder") $FileExists = FileExists(@ScriptDir & "\List.ini") If $FileExists - 1 Then $SetFolderRunning = 1 _SetFolder() Else $SetFolderRunning = 0 _Monitor() EndIf Func _SetFolder() $oDir = FileSelectFolder("Choose A folder to monitor", "My Computer") If @error Then Exit EndIf IniWrite(@ScriptDir & "\List.ini", "EN-US", "Dir", $oDir) _SetINI(1) EndFunc ;==>_SetFolder Func _SetINI($iRunCallMonitor) Local $hFirstFile, $oArrayString Dim $FilesArray[1] $hFirstFile = FileFindFirstFile($oDir & "\*.*") While 1 $oNextFile = FileFindNextFile($hFirstFile) If @error Then FileClose($hFirstFile) ExitLoop EndIf _ArrayAdd($FilesArray, $oNextFile) WEnd $oArrayString = _ArrayToString($FilesArray) IniWrite(@ScriptDir & "\List.ini", "EN-US", "Files", $oArrayString) $SetFolderRunning = 0 If $iRunCallMonitor = 1 Then _Monitor() EndFunc ;==>_SetINI Func _Monitor() While 1 Local $oReadDir, $oFiles, $String $oReadDir = IniRead(@ScriptDir & "\List.ini", "EN-US", "Dir", "1") If $oReadDir = 1 Then MsgBox(1, "Error", "Ini Read error: Could Not Read Directory Data" & @CRLF & "Please Delete the the INI file in the program Directory") Exit EndIf $oFiles = IniRead(@ScriptDir & "\List.ini", "EN-US", "Files", "1") If $oFiles = 1 Then MsgBox(1, "Error", "Ini Read error: Could Not Read Catelogued Files" & @CRLF & "Please Delete the the INI file in the program Directory") Exit EndIf $hFirstFileCheck = FileFindFirstFile($oReadDir & "\*.*") While 1 $oSearchFile = FileFindNextFile($hFirstFileCheck) If @error Then FileClose($hFirstFileCheck) ExitLoop EndIf _TraySystem() Sleep(100) _ArrayAdd($Array, $oSearchFile) WEnd $String = _ArrayToString($Array) Dim $Array[1] If StringCompare($String, $oFiles) <> 0 Then _TrayPopup($oFiles, $String, $oReadDir) Else EndIf WEnd EndFunc ;==>_Monitor Func _TraySystem() Switch TrayGetMsg() Case $hExit Exit Case $hDir _SetFolder() EndSwitch EndFunc ;==>_TraySystem Func _TrayPopup($iINI, $iArray, $iDir) Local $oString, $ReplaceString, $oFilesWrite $oString = StringCompare($iINI, $iArray) If $oString = -1 Then TrayTip("File Monitor", "A File Has Been removed from " & $iDir, 2, 2) $oFilesList = IniWrite(@ScriptDir & "\List.ini", "EN-US", "Files", $iArray) Else $ReplaceString = StringReplace($iArray, $iINI, " ") TrayTip("File Monitor", "A File (" & $ReplaceString & ") Has Been Added to " & $iDir, 2, 2) $oFilesList = IniWrite(@ScriptDir & "\List.ini", "EN-US", "Files", $iArray) EndIf EndFunc ;==>_TrayPopup Link to comment Share on other sites More sharing options...
MilesAhead Posted November 15, 2008 Share Posted November 15, 2008 For this type of task it may be simpler to let the OS watch for you using WM_FOLDER_CHANGE My Freeware Page Link to comment Share on other sites More sharing options...
argumentum Posted November 16, 2008 Share Posted November 16, 2008 For this type of task it may be simpler to let the OS watch for you usingWM_FOLDER_CHANGEcould you show me a quick sample? TIA 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...
wraithdu Posted November 16, 2008 Share Posted November 16, 2008 Or try this - SHChangeNotifyRegister() Link to comment Share on other sites More sharing options...
ptrex Posted November 17, 2008 Share Posted November 17, 2008 @AllOr this File / Folder monitorregards,ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New 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