#Persistent OnExit,Exit Menu, tray, NoStandard ; Menu, tray, add, Quick Add (file to Monitor), Addfile Menu, tray, add, Menu, tray, add, Check Now, CheckOnce Menu, tray, add, Menu, tray, add, Pause Monitoring, Pause Menu, tray, add, Start Monitoring, Start Menu, tray, add, Menu, tray, add, Control Panel, Monitorfilelist Menu, tray, add, Menu, tray, add, Preferences, Preferences Menu, tray, add, About, About Menu, tray, add, Menu, tray, add, exit, exit Menu, tray, tip, Currently Monitoring %TrayTipCount% for changes. Menu, tray, Disable,Start Monitoring IniRead, TimeCheck, %A_Scriptdir%\Backup Revision Folder.ini, time, TimeCheck, 3 IniRead, BackupFolder, %A_Scriptdir%\Backup Revision Folder.ini, Foldernames, Saveto, %A_MyDocuments%\Backup Revision Files IfNotExist, %A_Scriptdir%\links { MsgBox,4,, %A_Scriptname% requires to create a sub-directory called 'links'`nThis directory will be created if you proceed`nNo to Exit without creating `n`n%A_Scriptdir%\links IfMsgBox No Return FileCreateDir, %A_Scriptdir%\links } ;;; timer:=timeCheck*1000 ; SetTimer, TimeStampLoop, %timer% ;start timer Return ;;; TimeStampLoop: ; CheckOnce: Count:=0 Loop,%A_Scriptdir%\links\*.* ;loop the scripts folder for files { FileGetShortcut, %A_Loopfilelongpath%, OutTarget, OutDir, OutArgs, OutDesc, OutIcon, OutIconNum, OutRunState If Errorlevel=1 { Continue ;if not a shortcut, Continue } Count:=Count+1 ;for TrayTip FileGetTime, Timestamporig, %outtarget%,M If Errorlevel=1 { Continue } FileGetTime, Timestampsc, %A_Loopfilelongpath%,M If Errorlevel=1 { Continue } var1 = %Timestamporig% var2 = %Timestampsc% EnvSub, var1, %var2%, Seconds ;get the differerence in Seconds Between both files If Var1 not Between -3 and 3 ;sets the allowed Margin of Error Between timestamps +- three Seconds { FileSetTime,%timestamporig%,%A_Loopfilelongpath% If Errorlevel=1 { MsgBox,CRunch, BRF was unable to set the link file correctly, somethings wrong) } SplitPath, outtarget, name, dir, ext, name_no_ext, Drive ;get the details of the current looped file SetTimer, TimeStampLoop,off ;turn off the file Check timer BackUpFolderSubDirectory= %BackupFolder%\%name_no_ext% Backups monitoredfile=%outtarget% ;assign value to use outside loop Gosub, CreateGui } TrayTipCount=%Count% } Menu, tray, tip, Currently Monitoring %TrayTipCount% files for changes. Return ;;; CreateGUI: ; filetimemodified=%A_YYYY%_%A_MM%_%A_DD%_%A_Hour%_%A_Min% Gui,2: Destroy Gui,2: +AlwaysOnTop Gui,2: font,s10 Bold Gui,2: add, text,,%monitoredfile% - Detected change in save Status ;`n%Timestamporig% orig (Testing) `n%Timestampsc% sc (Testing)`n%var1% var1 Gui,2: font Gui,2: add, GroupBox, xm w620 h360 ,These comments to be Save to "%name_no_ext% HistoryLog.txt`" Gui,2: add, text, yp+25 x25 ,Added (+) Gui,2: add, edit, y+3 w600 r5 vHistoryAdded, Gui,2: add, text, y+10,Fixed or Repaired (*) Gui,2: add, edit, y+3 w600 r2 vHistoryFixed, Gui,2: add, text, y+10,Deleted (-) Gui,2: add, edit, y+3 w600 r2 vHistoryDeleted, Gui,2: add, text, y+10,And also these Details will be Automatically added to the history file `"%name_no_ext% HistoryLog.txt`" Gui,2: add, edit, y+3 w600 r6 vHistoryautomatic,Monitored filename = %monitoredfile%`nBackup filename = %BackUpFolderSubDirectory%\%name_no_ext%_%filetimemodified%.%ext%`nUser name = %A_Username% `nPC name = %A_Computername%`n Gui,2: font,s12 bold Gui,2: add, Button, y+30 w168 gguiclose, &Cancel (no save) Gui,2: add, Button,x+12 w418 gHitSubmit, &Save ,Submit to history log Gui,2: show,,Revision Backup of - %monitoredfile% Return ;;; HitSubmit: ; Gui,Submit IfNotExist, %BackUpFolderSubDirectory% { FileCreateDir, %BackUpFolderSubDirectory% } FileCopy, %monitoredfile%, %BackUpFolderSubDirectory%\%name_no_ext%_%filetimemodified%.%ext%, 0 FileAppend,`n------------------------------------------------------------------------`n%filetimemodified%,%BackUpFolderSubDirectory%\%name_no_ext%_HistoryLog.txt If Historyadded<> FileAppend,`n+%HistoryAdded%,%BackUpFolderSubDirectory%\%name_no_ext%_HistoryLog.txt If historyfixed<> FileAppend,`n*%historyfixed%,%BackUpFolderSubDirectory%\%name_no_ext%_HistoryLog.txt If historyDeleted<> FileAppend,`n-%historyDeleted%,%BackUpFolderSubDirectory%\%name_no_ext%_HistoryLog.txt FileAppend,`n%historyautomatic%,%BackUpFolderSubDirectory%\%name_no_ext%_HistoryLog.txt Gosub, FillListView 2Guiclose: Gui,2:Destroy TrayTip,Saving,%A_Scriptname%`nPerforming Save ,5,1 ;History File = %name_no_ext% HistoryLog.txt`nSaved in = %BackUpFolderSubDirectory%`nin directory = %A_Scriptdir% Sleep,3000 TrayTip, SetTimer, TimeStampLoop, %timer% Return ;;; Preferences: ; Gui,8:Destroy SetTimer, TimeStampLoop,off ;turn off the file Check timer Gui,8: Add, text,,Peform Check for changes every .. Gui,8:Add,edit,x+2 w50 Number vTimeCheck,%timeCheck% Gui,8: Add, text,x+2,Seconds Gui,8: Add, GroupBox, xm w460 h60 ,Location to Backup Folder Gui,8: Add,edit,x25 yp+22 w410 vBackupFolder ReadOnly,%BackupFolder% Gui,8: Add, Button,x+1 gSelectfolder,... Gui,8: font,s14 Gui,8: Add, Button,x25 y+30 gexitprefs ,&Cancel (no save) Gui,8: Add, Button,w220 gSavePrefs x+30,&Save Preferences Gui,8: show,,%A_Scriptname% Preferences Return Selectfolder: FileSelectFolder, SelectedFolder, , 3 If SelectedFolder = { MsgBox, You didn't select a folder. Return } Else GuiControl,, BackupFolder, %SelectedFolder% Return SavePrefs: Gui,8:Submit IniWrite, %TimeCheck%, %A_Scriptdir%\Backup Revision Folder.ini, Time, TimeCheck IniWrite, %BackupFolder%, %A_Scriptdir%\Backup Revision Folder.ini, Foldernames, Saveto Gui,8:Destroy timer:=timeCheck*1000 SetTimer, TimeStampLoop, %timer% Return exitprefs: 8GuiEscape: 8GuiClose: Gui,8:Destroy Return ;;; DeleteLink: ; RowNumber = 0 Loop { RowNumber := LV_GetNext(RowNumber) If not RowNumber Break LV_GetText(Text, RowNumber,5) LV_GetText(MFile, RowNumber,2) MsgBox,4,, Confirming that you are about to stop monitoring "%MFile%".`nThis action will NOT Delete any Master File`nThis action will NOT Delete any Backups `n`n(YES) to remove monitoring of this file. IfMsgBox No Return FileDelete,%text% } ;;; Monitorfilelist: ; ;GUI for list of files Gui, Destroy Gui, font, s12 bold Gui, add, text, x10 y5 ,Control Panel `n BRF v2.1 Gui, add, Button,x150 y5 w300 gAddfile,&Add a Monitored Link Gui, add, Button,x+50 y5 w300 gDeleteLink,&Remove a Monitored Link Gui, font Gui, add, Button,xm y+50 Section w120 gOpenFile,&Open/Run Master File Gui, add, Button,y+5 w120 gViewHistory,&View History of File Gui, add, Button,y+5 w120 gOpenRevisionFolder, &Explore Backup Folder Gui, add, Button,y+25 w120 gMonitorfilelist,Refresh &display Gui, add, Button,y+25 w120 gguiclose,&Close Gui, Add, ListView, ys-40 w680 r15 vlinkslistview gListBoxClick -Multi grid AltSubmit, Date|Monitored Master File|Last Edited Date|No# of Revisions|Monitored Link Name|Folder Kb Gui,show,,%A_Scriptname% ;;; FillListview: ; LV_Delete() ;Destroys the list in the ListView if Existing GuiControl, -Redraw, linkslistview Loop,%A_Scriptdir%\links\*.* ;loop the links folder for shortcuts { FileGetShortcut, %A_Loopfilelongpath%, OutTarget, OutDir, OutArgs, OutDesc, OutIcon, OutIconNum, OutRunState If Errorlevel=1 { Continue ;if not a shortcut, Continue } Else { SplitPath, outtarget, name, dir, ext, name_no_ext, Drive ;get the details of the current looped file FileGetTime, Timestampsc, %A_Loopfilelongpath%,M If Errorlevel=1 { Continue } b:=0 FolderSize = 0 Loop,%BackupFolder%\%name_no_ext% Backups\%name_no_ext%*.%ext% ;loop to Count how many revisions of file, must match name and ext { b:=b+1 ;the file Count FolderSize += %A_LoopFileSizeKB% } LV_Add("",timestampsc,outtarget,timestampsc,b,A_Loopfilelongpath,Foldersize " Kb " ) ;add to list view } } GuiControl, +Redraw, linkslistview LV_ModifyCol() LV_ModifyCol(1, "SortDesc") LV_ModifyCol(1,"Integer 0") LV_ModifyCol(3, "NoSort") ;NoSort for col 3 LV_ModifyCol(3,"110 Right") LV_ModifyCol(4,"100 Center") LV_ModifyCol(5,0) LV_ModifyCol(6,"70 Right") LV_ModifyCol(3, "Integer") LV_ModifyCol(3, "Desc") LV_Modify(1, "Select") Return ;;; ListBoxClick: ; ;if mouse clicked on header date column If ( A_GuiEvent = "ColClick" And A_EventInfo = 3 ) { If Sort LV_ModifyCol(1, "Sort") Else LV_ModifyCol(1, "SortDesc") Sort := not Sort } Return ;;; guiclose: guiescape: Gui, Destroy Return Addfile: ; Gui +OwnDialogs ;Forces user to dismiss the following dialog before using main window. FileSelectFile, SelectedFile, 3, , Open a file If SelectedFile = MsgBox, The user didn't select anything. Else { SplitPath, selectedfile, sname, sdir, sext, sname_no_ext, sDrive ;get the details of the current looped file FileCreateShortcut, %selectedfile%, %A_Scriptdir%\links\%sname%.lnk Gosub, FillListView } Return ;;; ViewHistory: ; RowNumber = 0 Loop { RowNumber := LV_GetNext(RowNumber) If not RowNumber Break LV_GetText(Text, RowNumber,2) SplitPath, text, Hname, Hdir, Hext, Hname_no_ext, HDrive Run,%BackupFolder%\%Hname_no_ext% Backups\%Hname_no_ext%_HistoryLog.txt,,Max UseErrorLevel If ErrorLevel = Error MsgBox The document could not be Found. } Return ;;; OpenRevisionFolder: ; RowNumber = 0 Loop { RowNumber := LV_GetNext(RowNumber) If not RowNumber Break LV_GetText(Text, RowNumber,2) SplitPath, text, Hname, Hdir, Hext, Hname_no_ext, HDrive Run,%BackupFolder%\%Hname_no_ext% Backups,,Max UseErrorLevel If ErrorLevel = Error MsgBox The Folder could not be Found. } Return ;;; OpenFile: ; RowNumber = 0 Loop { RowNumber := LV_GetNext(RowNumber) If not RowNumber Break LV_GetText(Text, RowNumber,2) Run,%text% ,,Max UseErrorLevel If ErrorLevel = Error MsgBox The File could not be Opened. } Return ;;; Pause: ; ;pause the timer SetTimer, TimeStampLoop,off Menu, tray, Disable,Pause Monitoring Menu, tray, Enable,Start Monitoring Menu, tray,tip, Currently Paused Monitoring Return Start: ;restart the timer SetTimer, TimeStampLoop, %timer% Menu, tray, Enable,Pause Monitoring Menu, tray, Disable,Start Monitoring Menu, tray,tip, Curently Monitoring %TrayTipCount% files for changes. Return ;;; ABOUT: ; Gui,9:Font,Bold Gui,9:Add, GroupBox,x6 y5 w400 h125 ,Description Gui,9:Font Gui,9:Add,Text,x15 y23, ( '%A_Scriptname%' It is used to save copies incrementally, of any file chosen to be monitored. The user can Add notes to a HistoryLog file to be kept with the backups. Application can be used Standalone on PC, or used on a thumb Drive. Just add files to be monitored from the tray menu or Control Panel. ) Gui,9:Add,Text,y+0,`t Gui,9:Font,Bold Gui,9:Add,GroupBox,x6 y145 w400 h240,DonationCoder Gui,9:Font Gui,9:Add,Text,x20 y165,Please support the DonationCoder community Gui,9:Font,CBlue underline Gui,9:Add,Text,y+3 GDONATIONCODER,www.DonationCoder.com Gui,9:Font Gui,9:Add,Text,y+0,`t Gui,9:Font,Bold Gui,9:Add,Text,y+3 yp+10,AutoHotkey Gui,9:Font Gui,9:Add,Text,y+3,This program was made using AutoHotkey Gui,9:Font,CBlue underline Gui,9:Add,Text,y+3 GAUTOHOTKEY,www.AUTOHOTKEY.com Gui,9:Font Gui,9:Add,Text,y+0,`t Gui,9:Font,Bold Gui,9:Add,Text,y+3 ,Made by Brett (DoubleBogey) Gui,9:Font Gui,9:Add,Text,y+3,Find more mini-apps like this`, visit Gui,9:Font,CBlue underline Gui,9:Add,Text,y+3 GDONATIONCODER,www.DonationCoder.com Gui,9:Font Gui,9:Add,Text,y+0,`t Gui,9:Font,Bold Gui,9:Add,Text,y+3 ,Visit Skrommels 1 Hour Software Gui,9:Font Gui,9:Add,Text,y+3,Great AHK scripts, and handy to learn from. Gui,9:Font,CBlue underline Gui,9:Add,Text,y+3 GSkrommel,http://www.donationcoder.com/Software/Skrommel/ Gui,9:Add,Button,xm GABOUTOK Default w75,&OK Gui,9:Show,,About %A_Scriptname% Return ABOUTOK: Gui, 9:Destroy Return DONATIONCODER: Run,http://www.donationcoder.com,,UseErrorLevel Return Skrommel: Run,http://http://www.donationcoder.com/Software/Skrommel/,,UseErrorLevel Return AUTOHOTKEY: Run,http://www.autoHotkey.com,,UseErrorLevel Return ;;; exit: ExitApp