AutoHotkey: IdleWorker

Description

  • Do you want to utilize your computer power when it is idle?
  • Do you need maintenance tasks to be executed regularly and without disturbing you when you are working with your computer?
  • Do you execute these tasks from the Task scheduler and often notice it starts and drain your machine performance at the most inappropriate moments?
  • Are you a power user that do not hesitate and fear to maintain program configuration through ini files?

Then you are the target audience for the IdleWorker project

The IdleWorker is special task manager for Windows 2000/XP/Vista that can:

  • Execute tasks when your computer is idle
    • and screensaver is running
      • or workstation is locked or fast-user-switch screen is active
    • and CPU average load is under specified threshold
    • and your computer is not running on batteries
    • only on specified days of week
    • only during specific time periods
    • with specific priority or window mode or hidden


Another features include:

  • Logging with logs rotation
  • Status window with lightweight log
  • Status file for use in Samurize
  • Actual status written into registry for use by external modules
  • Automatic ini file reload on change

Programmed in AutoHotkey.

Configuration

Configuration is stored in idleworker.ini file. Currently there is no GUI for editing configuration.
One should use text editor to change configuration in idleworker.ini file. The running IdleWorker is
monitoring that file and will reload any changes automatically.

[settings]

idleTime
(number) Minimum user inactivity time in seconds. 1)
Example, ten minutes: idleTime=10*60
waitForScreensaver
(yes/no) If set to yes, IdleWorker will wait for screensaver even if idleTime already passed
disableOnBatteries
(yes/no) Disable IdleWorker if machine is running on batteries
disableUnderBatteryPercent
(number) Battery charge level in percent under which the monitoring will be disabled. disableOnBatteries must be yes. 2)
Example: disableUnderBatteryPercent=60
maxAverageCPULoad
(number) Maximum average CPU load in percent. Tasks will not be run until CPU is over this limit. Set to 0 to disable. 3)
Example: maxAverageCPULoad=40
monitorIni
(yes/no) Enable configuration reloading of idleworker.ini when file modification time changes.
showTooltips
(yes/no) Show informational baloon tooltips (WinXP+)
showTooltipsIfScreensaver
(yes/no) Show balloon tooltips even when screensaver is running

[log]

logFile
(string) Filename of log file. When empty, idleworker.log in IdleWorker directory will be used.
Example: logFile=c:\log\idleworker.log
clearLog
(yes/no) Clear log file on each IdleWorker start.
maximumLogSize
(number) Maximum log file size in bytes. As soon as the log file grows to defined size, it is rotated. 4)
Example, 100 kiloBytes: maximumLogSize=100*1024
logRotateCount
(number) Maximum number of rotated logs to hold. 5)
Example: logRotateCount=5
showLogCmd
(string) Command used for watching of log file. If not specified, default application for .LOG extension is used.
Use %logfile% variable in place of command line parameter. It will be replaced by actual log filename.
Example: showLogCmd=wintail.exe %logfile%

[gui]

This section is automatically updated on exit with actual position of status window.

statsWindowX
statsWindowY
statsWindowWidth
statsWindowHeight

[tasks]

tasksRunOrder
(list of strings) Order in which tasks (see below) will be run. Use task names (taskName parameter) or task numbers.
This parameter is optional. If not used, implicit tasks ordering will be used.
Example: tasksRunOrder=malware_scan,defrag_fast,boinc
Example: tasksRunOrder=malware_scan,1,3
Example: tasksRunOrder=0,1,3,2

[taskN]

Each task specification must have its own section. Each task section starts with task followed by task number N ([task8]). Duplicit task numbers are not allowed. There can be holes in task numbering.

Each [taskN] section can contain following parameters:

taskName
(string) Optional task name. This name is used in log files, status screen and can be used inside tasksRunOrder parameter.
This parameter is optional and if not used, task is referred to by its number.
Example: taskName=defrag_fast
taskStart
(string) Complete path to command used to start the task.
Example: taskStart=C:\winapp\Defrag\jkDefrag\JkDefragCmd.exe
taskStartParams
(string) Optional list of parameters for taskStart command.
Example: taskStartParams=-a 3 -d 1 -l “c:\log\jkdefrag.log” c:\
taskStop
(string) Optional complete path to command used to stop the task.
Usually IdleWorker can stop running task simply by referring to its PID and sending WM_CLOSE to task process. Some processes though
cannot be stopped this way or it is inconvenient. Such tasks may provide special command line parameters to stop its processes or
even another executable for stopping it.
Example:
taskStop=C:\winapp\BOINC\boinccmd.exe
taskStopParams=–quit
taskStartMode
(normal/min/max/hide) Optional mode for task main window on task start. If not specified, normal is used and task normally opens its window.
You may usually wish to start the task hidden or at least minimized.
Example: taskStartMode=Hide
taskStopMode
Same as for taskStartMode
priority
(Low/BelowNormal/Normal/AboveNormal/High) Initial process priority for the task. Priority is set immediatelly after task start.
Note that some tasks may set their priority to different level after start and anywhere during execution. In such case, this parameter will have no effect.
allowedRunningTime
(number) Optional maximum allowed running time in seconds. Task will be stopped forcefully after given granted time. 6)
Example: allowedRunningTime=30*60

limitDays
(Mon/Tue/Wed/Thu/Fri/Sat/Sun) Optional list of week days on which the task is allowed to run.
Example, run only on weekends: limitDays=Sat,Sun
limitTime
(time periods) Optional, same as limitDays, but specify time of day.
Example, run during lunchtime and overnight: limitTime=12:00-13:00,20:00-05:00
leaveRunning
(yes/no) Optional. If set to yes, task will continue running even when user activity is detected.
runOnce
not implemented yet

Code and download

ahk-idleworker-1.2.zip

Icons

Give a try to some excellent icons sets that can be used as IdleWorker status icons in place of default:

CoffeeBreak Icons

AquaCandy Icons

GreenVille Icons

LonghornObjects Icons

LastOrder Icons
LastOrderCandy Icons
LastOrderPlus Icons

Source code

FIXME

Not yet available

Configuration example

This is example configuration that will:

In order

  1. Execute malware scan (only on monday)
  2. Execute full disk defragmentation (only on monday)
  3. Execute fast disk defragmentation (on all days except monday)
  4. Execute BOINC client (everyday)


further criteria are:

  • User idle time must be at least 10 minutes or workstation lock/fast user switch screen must be active
  • Screen saver must be running
  • Computer must not be running on batteries
  • Average CPU load must be under 40%


Following is example idleworker.ini file.

Download

IdleWorker.ini example

[settings]
; Idle time in seconds
;idletime=10
idletime=15*60
; Wait for screensaver
waitForScreensaver=yes
; Disable if machine is running on batteries
;disableOnBatteries=yes
; Battery charge level under which the monitoring will be disabled (%)
disableUnderBatteryPercent=50
; Maximum average CPU load. Tasks will not be run until CPU is over this limit. Set to 0 to disable
maxAverageCPULoad=40
 
; Monitor this ini for changes and reload
monitorini=true
; Show baloon tooltips (WinXP+)
showTooltips=yes
showTooltipsIfScreensaver=no
 
[gui]
statsWindowX=581
statsWindowY=23
statsWindowWidth=500
statsWindowHeight=571
 
[log]
logfile=c:\winapp\idleworker\idleworker.log
; Optional
;clearlog=true
; Optional - In bytes
maximumlogsize=100*1024
; Optional
logrotatecount=4
showLogCmd=C:\winapp\Develope\AutoHotkey\AutoHotkey.exe C:\winapp\WinTail\baretail.ahk "%logfile%"
 
[tasks]
; Optional
tasksRunOrder=malware_scan,defrag_full,defrag_fast,boinc
 
[task0]
; Optional
taskName=defrag_fast
 
taskStart=C:\winapp\Defrag\jkDefrag\JkDefragCmd.exe
taskStartParams=-a 3 -d 1 -l "c:\log\jkdefrag.log" c:
; Optional
taskStartMode=Min
 
; Optional
taskStop=
 
; Optional. values = Low, BelowNormal, Normal (default), AboveNormal, High
priority=
 
; Optional. Maximum allowed running time in seconds
allowedRunningTime=
 
; runOnce=XX,YY Run only once per YY minutes if it already has been running at least XX minutes
runOnce=10,60
 
; Normal (default), Min, Max, Hide
; Mon,Tue,Wed,Thu,Fri,Sat,Sun, leave empty for all
limitDays=Tue,Wed,Thu,Fri
limitTime=00:00-23:59
 
[task1]
; Optional
taskName=defrag_full
 
taskStart=C:\winapp\Defrag\jkDefrag\JkDefragCmd.exe
taskStartParams=-a 4 -d 1 -l "c:\log\jkdefrag.log" c:
; Optional
taskStartMode=Min
 
; Optional
taskStop=
 
; Optional. values = Low, BelowNormal, Normal (default), AboveNormal, High
priority=
 
; Optional. Maximum allowed running time in seconds
allowedRunningTime=
 
; runOnce=XX,YY Run only once per YY minutes if it already has been running at least XX minutes
runOnce=10,60
 
; Normal (default), Min, Max, Hide
; Mon,Tue,Wed,Thu,Fri,Sat,Sun, leave empty for all
limitDays=Mon
limitTime=00:00-08:00
 
[task2]
taskName=boinc
 
taskStart=C:\winapp\BOINC\boinc.exe
taskStartMode=Min
 
taskStop=C:\winapp\BOINC\boinccmd.exe
taskStopParams=--quit
taskStopMode=Hide
 
[_task3]
taskname=malware_scan
 
taskStart=C:\winapp\antivir\a-squared\cmdscan.cmd
taskStartMode=Min
 
taskStop=pskill
taskStopParams=a2cmd
taskStopMode=Hide
 
limitDays=Mon
leaveRunning=yes
runOncePerDay=true

Changelog

  • version 1.2
    • Fixed behavior on wakeup from standby/hibernation
  • version 1.1 - First release

Bugs / Known issues

TODO

  1. Create GUI configuration editor
1) , 2) , 3) , 4) , 5) , 6) Simple algebraic expression can be used (+-*/)

Discussion

KBFLC
 
projects/autohotkey/idleworker.txt · Last modified: 2007/04/20 19:29 UTC by pavel
 
Recent changes RSS feed Creative Commons License Donate to DokuWiki author Valid XHTML 1.0 Valid CSS Driven by DokuWiki Debian served Run on Apache Powered by PHP eAccelerated