Here is a small autohotkey program that I made because I needed it. I'll package it up more nicely some other time. Instead of a timer it would of course be cooler with some brain-sensor hardware device so that shutdown can occur right after you fall asleep
. But this works pretty well too
. Any suggestions on improving it? (Feel free to add code.)
;-- AudioBookSleep v090226
;-- by Nod5
;-- description: the program waits X minutes, then saves a screenshot of the VLC window to the desktop, then shuts down the computer
;-- The VLC screenshot shows the filename and time just before shutdown and makes it easier to next time continue from where you dozed off.
;--
;-- use case: you listen to audiobooks at night but often fall asleep.
;-- You then awake hours later (at 3:23 AM) from the laptop light and audiobook sound.
;-- You dislike having to go up and turn it off manually. And now you're unsure at what point in the book you fell asleep.
;-- Even worse, when you woke up you heard some part from latter chapters that gives away the plot!
;-- You wish for some automatic screenshot-then-shutdown timer.
;-- So you start to use AudioBookSleep
;--
;-- note: for screencaps you need minicap.exe by Mouser -- https://www.donationcoder.com/Software/Mouser/MiniCap/
InputBox, xvar, sleep timer, Set time in minutes until computer shutdown, ,350,150,,,,,30
if errorlevel = 1
exitapp
if errorlevel = 2
exitapp
ifexist %A_ProgramFiles%\minicap\minicap.exe
xpath = %A_ProgramFiles%\minicap\minicap.exe
else ifexist %A_scriptdir%\minicap.exe
xpath = %A_ProgramFiles%\minicap\minicap.exe
if xvar != test
{
if xvar is not integer
exitapp
xvar := xvar * 60000
sleep, %xvar%
}
IfWinExist, ahk_class QWidget ;-- screencap VLC window
{
WinActivate, ahk_class QWidget
WinWaitActive, ahk_class QWidget
sleep 500
if xpath !=
run %A_ProgramFiles%\minicap\minicap.exe -captureactivewin -save "%A_Desktop%\sleep.jpg" -exit
}
if xvar != test
Shutdown, 9
edit: corrected the default time in the code to 30 minutes