Running scandisk, virus scan, defrag, backup and all that stuff is important.
yeah, yeah... we all know that! But frankly, how often do we do that? ... not untill its too late... ain't I right?
Even scheduling doesn't help much coz when the assigned time comes we're doing something terribly important to let a disk scan interfere.
... so to take care of us procrastinators I've started an open ended project to run all these tasks, one after another, as a single macro... All this is run as a screensaver, and runs when u're not using the pc. I've already created the outer shell, the configurator, and added a support for some tools to demonstrate the use.
It'd be nice if you give it a try. But more important is creating your own modules and adding them (with AutoScriptWriter it should be a breeze). The basic guidelines for adding a new module are in the script.
Misc Notes:
- The script, when run, compiles itself to .scr (nice, eh?) but during testing, debugging etc. set the var DebugMode = 1 and it will run without compiling itself.
- To configure the apps, rt. click and select Configure on compiled script.
Code:
/*
___________________________________________
System (Screen)Saver
___________________________________________
Available Modules:
HDDlife (hdlife.com) checks HD health
SpyBot (www.spybot.info) malware remover
NDD (www.symantec.com) Norton Disk Doctor (quite old)
VOptXP (goldenbow.com) drive defragmenter
CMD defrag (windows tool) drive defragmenter
Guidelines:
- The module must be complete in itself, without needing
any user interaction.
- No two modules must be running at the same time! Even
if one module generates some output which requires the
user to decide what he wants to do (eg. Spybot), next
module must start only when the current one is idle and
just waiting for user to decide further action.
- Two places require modifying while adding a new module:
- Adding module's section to end of script
- Adding its section name to the list of Modules below
- If the module generates a msgbox etc. requiring interaction,
the occurrance of which is uncertain, then add its support
in the Timer section.
- Don't use any characters for section names that are not
valid for variable names (eg. - + / etc.). Space can be
used.
- For testing etc. set the DebugMode var to 0 to stop script
from compiling itself and exiting.
___________________________________________
___________________________________________
*/
Modules = HDDlife|SpyBot|NDD|VOPT|CMD Defrag
; Add New Module name here ^
DebugMode = 0
;___________________________________________
SetTitleMatchMode, Slow
MainWin = SystemSaver
; this is a separator for reports
BR = `n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-`n`n
; Self Compiling
IfNotEqual, DebugMode, 1
IfInString,A_ScriptName,.ahk
{
StringTrimRight,name,A_ScriptName,4
RegRead,cmd,HKEY_CLASSES_ROOT,AutoHotkeyScript\Shell\Compile\Command
StringTrimRight,cmd,cmd,4
IfEqual,out,,StringReplace,out,A_ScriptFullPath,.ahk,.scr IfNotInString,out,.scr,SetEnv,out,%out%\%name%.scr StringReplace,out,out,\\,\,All
SetEnv,cmd,%cmd% "%A_ScriptFullPath%" /out "%out%"
SetEnv,msg,Input`t`t%A_ScriptFullPath%`nOutput`t`t%out%
If icon>
{
SetEnv,cmd,%cmd% /icon "%icon%"
SetEnv,msg,%msg%`nIcon`t`t%icon%
}
MsgBox,1,Compile this script?,%msg%
IfMsgBox,ok,Run,%cmd%
ExitApp
}
;___________________________________________
IfEqual, 1, /P, GoTo, Preview
IfNotInString, 1, /s, GoTo, Config
SetTimer, Timer, 200
SplashImage,, W230 H50 B1 X0 Y0, ->, Press ESC to close SysSaver,
IniRead, ToRun, %A_ScriptDir%\SysSaver.ini, Settings, ToRun
IfEqual, ToRun, ERROR
ToRun =
Loop, Parse, ToRun, |
{
IfEqual, A_LoopField,, Continue
StringReplace, SectionName, A_LoopField, %A_Space%,, A
IfNotInString, SectionName, CMDDefrag
{
CurrModNoSpace = %SectionName%
CurrModPth := %CurrModNoSpace%Pth
IfNotExist, %CurrModPth%
IniRead, CurrModPth, %A_ScriptDir%\SysSaver.ini, Paths, %CurrModNoSpace%
IfEqual, CurrModPth, ERROR
{
FileSelectFile, CurrModPth,,, Select %CurrMod% Executable
IfNotEqual, ErrorLevel, 0, Return
}
%CurrModNoSpace%Pth = %CurrModPth%
IniWrite, %CurrModPth%, %A_ScriptDir%\SysSaver.ini, Paths, %CurrModNoSpace%
}
;spl treatment for defrag drive
IfInString, SectionName, CMDDefrag
{
StringRight, TgtDrive, SectionName, 1
GoSub, CmdDefrag
}
Else
Gosub, %SectionName%
}
SplashImage,,,
FileDelete, %temp%\report.log
IfNotEqual, Report,
{
FileAppend, %Report%, %temp%\report.log
Run, Notepad %temp%\report.log
}
ExitApp
;___________________________________________
; Special Sections
;___________________________________________
Preview:
;splashtext saying 'Rajat Ownz' here ;)
ExitApp
Config:
Sort, Modules, D|
IniRead, ToRun, %A_ScriptDir%\SysSaver.ini, Settings, ToRun
IfEqual, ToRun, ERROR, SetEnv, ToRun,
Gui, Add, ListBox, x15 y46 w120 h173 vAllMods, %Modules%
Gui, Add, ListBox, x175 y46 w120 h173 vSelMods, %ToRun%
Gui, Add, Button, x145 y96 w20 h20 vAdd, >
Gui, Add, Button, x145 y146 w20 h20 vRem, <
Gui, Add, GroupBox, x15 y1 w280 h31 ,
Gui, Add, Button, x56 y287 w80 h20, OK
Gui, Add, Button, x156 y287 w90 h20, Cancel
Gui, Add, GroupBox, x26 y269 w253 h53,
Gui, Font, S12 C4A7777 Bold
Gui, Add, Text, x20 y9 w270 h18 +Center, %MainWin%
Gui, Show, x276 y99 h333 w308, %MainWin%
Return
Button>:
GuiControlGet, CurrMod,, AllMods
;ask drive to defrag
IfEqual, CurrMod, CMD Defrag
{
InputBox, Drive, Enter Drive ID:,,, 200, 90
IfNotEqual, ErrorLevel, 0, Return
IfEqual, Drive,, Return
StringLeft, Drive, Drive, 1
StringUpper, Drive, Drive
CurrMod = CMD Defrag %Drive%
CmdDefrag%Drive%Pth = %windir%\system32\defrag.exe
GuiControl,, SelMods, %CurrMod%
Return
}
StringReplace, CurrModNoSpace, CurrMod, %A_Space%,, A
CurrModPth := %CurrModNoSpace%Pth
IfNotExist, %CurrModPth%
IniRead, CurrModPth, %A_ScriptDir%\SysSaver.ini, Paths, %CurrModNoSpace%
IfEqual, CurrModPth, ERROR
{
FileSelectFile, CurrModPth,,, Select %CurrMod% Executable
IfNotEqual, ErrorLevel, 0, Return
}
%CurrModNoSpace%Pth = %CurrModPth%
IniWrite, %CurrModPth%, %A_ScriptDir%\SysSaver.ini, Paths, %CurrModNoSpace%
GuiControl,, SelMods, %CurrMod%
Return
Button<:
GuiControlGet, CurrTool,, SelMods
;get selected entry
SendMessage, 0x188, 0, 0, ListBox2, %MainWin%
CurrCnt = %ErrorLevel%
;Del selected Entry
SendMessage, 0x182, %CurrCnt%, 0, ListBox2, %MainWin%
Return
ButtonOK:
ControlGet, ModList, List,, ListBox2, %MainWin%
StringReplace, ModList, ModList, `n, |, A
IniWrite, %ModList%, %A_ScriptDir%\SysSaver.ini, Settings, ToRun
ExitApp
Return
Esc::
ButtonCancel:
GuiClose:
ExitApp
;___________________________________________
; Timer
;___________________________________________
Timer:
IfWinExist, Norton Disk Doctor, The operating system
{
WinActivate
Send, N
}
Return
;___________________________________________
; Place Modules Here
;___________________________________________
HDDlife:
SplashImage,,, HDDlife
CurrPth := %SectionName%Pth
Run, %CurrPth%
WinWait, HDDlife, conclusion:
WinActivate, HDDlife, conclusion:
WinWaitActive, HDDlife, conclusion:
PostMessage, 0x111, 137,,, HDDlife, conclusion: ;save dialog
WinWait, Save As
WinActivate, Save As
WinWaitActive, Save As
FileDelete, %temp%\report.log
Send, %temp%\report.log{Enter}
Sleep, 500
WinWaitActive, HDDlife, conclusion:
PostMessage, 0x111, 161,,, HDDlife, conclusion: ;exit
FileRead, tmpReport, %temp%\report.log
FileDelete, %temp%\report.log
Report = %BR%`n`n%tmpReport%
Return
SpyBot:
SplashImage,,, Spybot - S & D
CurrPth := %SectionName%Pth
Run, %CurrPth%
WinWait, Spybot - Search & Destroy, Search for Updates
WinActivate, Spybot - Search & Destroy, Search for Updates
WinWaitActive, Spybot - Search & Destroy, Search for Updates
ControlClick, TBitBtn3, Spybot - Search & Destroy, Search for Updates
Loop
{
Sleep, 1000
IfWinNotExist, Spybot - Search & Destroy, Running bot-check
Break
}
Return
NDD:
SplashImage,,, Norton Disk Doctor
CurrPth := %SectionName%Pth
Run, %CurrPth%
WinWait, Norton Disk Doctor, &Diagnose
WinActivate, Norton Disk Doctor, &Diagnose
WinWaitActive, Norton Disk Doctor, &Diagnose
ControlClick, Button1, Norton Disk Doctor, &Diagnose
WinWait, Test Results for Drive
WinActivate, Test Results for Drive
WinWaitActive, Test Results for Drive
ControlClick, Button1, Test Results for Drive
WinWait, Norton Disk Doctor, &Diagnose
WinActivate, Norton Disk Doctor, &Diagnose
WinWaitActive, Norton Disk Doctor, &Diagnose
ControlClick, Button4, Norton Disk Doctor, &Diagnose
Return
VOPT:
SplashImage,,, VoptXP Defrag
CurrPth := %SectionName%Pth
Run, %CurrPth%
WinWait, VoptXP
WinActivate, VoptXP
WinWaitActive, VoptXP
PostMessage, 0x111, 6,,, VoptXP ;global defrag
Return
; this module should not be seen as a model
; it works differently than others.
CmdDefrag:
SplashImage,,, Defragmenting %TgtDrive%:
RunWait, %ComSpec% /c Defrag %TgtDrive%: -v > %temp%\report.log,, Min
TgtDrive =
FileRead, tmpReport, %temp%\report.log
FileDelete, %temp%\report.log
Report = %BR%`n`n%tmpReport%
Return