AutoHotkey Community

It is currently May 24th, 2012, 1:52 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: SystemSaver
PostPosted: March 6th, 2005, 10:13 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1865
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.

Image

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


_________________
Image


Last edited by Rajat on March 6th, 2005, 10:37 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2005, 10:27 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Great idea! I will try it. Thanks for sharing.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2005, 10:52 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Nice script Rajat. :) I was trying to automate Spybot S+D and AdAware last week. Its a real shame these apps don't support command line parameters (or do they?). I found the results with Scriptwriter too vague to handle file updates and I like to see what they've found before deleting them.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2005, 10:56 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1865
Serenity wrote:
Nice script Rajat. :) I was trying to automate Spybot S+D and AdAware last week. Its a real shame these apps don't support command line parameters (or do they?). I found the results with Scriptwriter too vague to handle file updates and I like to see what they've found before deleting them.

that is the reason i've automated SpyBot only till it completes its scan and not automated the cleaning part... given a free reign it'd probably render all p2p tools useless!

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 7th, 2005, 4:36 am 
Rajat, is it possible for you to make this script/utility to show the reminders like if you specify the time and date it will bring up the reminder in a pop box or as an alarm clock- If I put the wake up call at 9:00 am it will start playing the song that I specifed at 9:00 am in the morning?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2005, 4:42 am 
Offline

Joined: October 27th, 2004, 1:22 am
Posts: 64
Location: GA
Sorry I was thinking of something else when I posted the last message (as a Guest) :oops:

But I realize it might not be easy as I think, so don't be so worried, Rajat :)
Eventhough for a guy like you it might be few minutes of scripting in your free time :wink:

_________________
-Tru 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2005, 8:32 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1865
tpatel5 wrote:
Sorry I was thinking of something else when I posted the last message (as a Guest) :oops:

But I realize it might not be easy as I think, so don't be so worried, Rajat :)
Eventhough for a guy like you it might be few minutes of scripting in your free time :wink:

that idea is not going to be a part of this script buddy... but a standalone script to serve as alarm clock would probably be the easiest script in forum. here're the pointers : create a timer. check current time. compare with set alarm time. show msg/play song/call office to say u're sick.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2005, 3:21 pm 
Offline

Joined: October 27th, 2004, 1:22 am
Posts: 64
Location: GA
No problem. :)

For me to have a graphic like yours in my signature do I have to upload my gif to some website and have to use that link? I tried copy and paste in the signature box didn't work :(

_________________
-Tru 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2005, 3:58 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
tpatel5 wrote:
For me to have a graphic like yours in my signature do I have to upload my gif to some website and have to use that link? I tried copy and paste in the signature box didn't work :(
ImageShack ?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2005, 8:33 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
tpatel, would it be a bit much to ask to get a smaller, less distracting picture? I used to have a graphic sig, and brought it down for those reasons, but even when I did have one the text of my posts was usually larger than the sig itself. :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2005, 8:39 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1865
i agree with jonny... but would somebody post here something that is related to this topic?

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2005, 2:09 pm 
Offline

Joined: March 4th, 2005, 1:42 pm
Posts: 39
Location: Netherlands
Serenity wrote:
Nice script Rajat. :) I was trying to automate Spybot S+D and AdAware last week. Its a real shame these apps don't support command line parameters (or do they?). I found the results with Scriptwriter too vague to handle file updates and I like to see what they've found before deleting them.

If you want to automate SpyBot S&D, AdAware and other Anti Spyware tools, take a look at Hitman Pro. It incorporates both tools, and more. It also includes the possibility to automatically update the definitions files of the tools used.

There is one caveat though: it's in Dutch! :? (that's why I post it only here, not in the Utilities forum). No problem for me, as it is my native language, but may be difficult for you. Babelfish may help, though!
BTW, there's a compiled AutoIt3 script included in the program, so maybe someone can learn something from it by uncompiling?

_________________
The Gods smile upon you. Beware - it is probably because they know what is going to happen to you next, and find it amusing. To them, anyway. --- Discworld Horrorscope: http://www.weirdnes.force9.co.uk/stars3.html


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2005, 2:32 pm 
Quote:
Its a real shame these apps don't support command line parameters (or do they?).

Quote:

Quote:
Spybot-S&D

Detection updates 2005-03-03
This updates the detection rules. Only needed if you do not want to use the update function integrated into Spybot-S&D.

---> http://www.spybotupdates.com/updates/fi ... cludes.exe

Advanced check library update 2004-10-14
This is an update for a detection library. Only needed if you do not want to use the update function integrated into Spybot-S&D.

---> http://www.spybotupdates.com/updates/fi ... vcheck.exe


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], cmulcahy, Exabot [Bot], MSN [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group