I recently saw mention of a time-keeping application that takes screen shots of your desktop every 5 minutes or so. At the end of the week you can then play back your week to see what you did and figure out who to bill for what. This sounded like a great tool to me because I often forget what I was doing on a given day when reviewing my timesheet so I end up looking at my sent email for that time slot to try and jog my memory.
I figured what this program was doing is actually really simple and I could do it myself so I took a stab at it and cobbled the following script together. Unfortunately it has a couple dependencies: Imagemagick and Boxcutter. Look at the comments below for more info.
[vb]’ VB Script to take time-stamped screenshot and convert to JPEG
‘ Setup to run from Scheduled Tasks every 5 minutes to have a record of what
‘ you did this week
‘
‘ NOTES
‘ It doesn’t clean up after itself
‘ On my machine with 1280×800 display if it runs every 5 minutes with quality
‘ set to 40 it uses around 30MB every day for image storage. After 30 days
‘ that’s 900 MB!
‘ You can adjust the quality to increase or decrease file size.
‘ Imagemagick is required. It is used to convert the BMP to JPEG.
‘ The convert command from Imagemagick must be on the path
‘ The Boxcutter program is required. You can download it from here:
‘ http://rasm.ods.org/boxcutter/
‘ Place this VBS in the same directory that you extract boxcutter.
Public Const OUTPUTPATH = “d:\screenshots”
Public Const TEMPFILE = “c:\newss.bmp”
Public const JPEG_QUALITY = 40
Function PadDigits(n, totalDigits)
PadDigits = Right(String(totalDigits,”0″) & n, totalDigits)
End Function
Sub DoIt()
Dim WSHShell
Set WSHShell = WScript.CreateObject(“WScript.Shell”)
Dim oFSO
Set oFSO = WScript.CreateObject(“Scripting.FileSystemObject”)
dim fileName, folderName, folderPath
folderName = “” & Year(Now) & PadDigits(Month(Now), 2) & PadDigits(Day(Now), 2)
fileName = folderName & “_” & PadDigits(Hour(Now), 2) & PadDigits(Minute(Now), 2) & PadDigits(Second(Now), 2) & “.jpg”
folderPath = OUTPUTPATH & “\” & folderName
‘ Take screen shot
‘ 7 means new window is minimized
call WSHShell.Run (“boxcutter.exe -f ” & TEMPFILE, 7)
WScript.Sleep 3000
If Not oFSO.FolderExists(OUTPUTPATH) Then
‘ Create folder if it doesn’t exist
Call oFSO.Createfolder(OUTPUTPATH)
End If
If Not oFSO.FolderExists(folderPath) Then
‘ Create folder if it doesn’t exist
Call oFSO.CreateFolder(folderPath)
End If
‘ Convert to JPEG
‘ 7 means new window is minimized
call WSHShell.Run (“convert -quality ” & JPEG_QUALITY & ” ” & TEMPFILE & ” ” & folderPath & “\” & fileName, 7)
WScript.Sleep 3000
If oFSO.FileExists(TEMPFILE) Then
‘ Delete bmp file
Call oFSO.DeleteFile (TEMPFILE)
end If
End Sub
‘ actually run our Sub above
DoIt
[/vb]