topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 6:50 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: AudioBookSleep  (Read 11701 times)

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
AudioBookSleep
« on: February 26, 2009, 03:57 PM »
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  8). 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
« Last Edit: February 26, 2009, 04:47 PM by Nod5 »

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,747
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: AudioBookSleep
« Reply #1 on: February 26, 2009, 04:17 PM »
Looks like a useful little script. Except I don't usually have my computer in my bedroom, and couldn't stand wearing earphones to bed.

Any suggestions on improving it?

How about adding that brain-sensor? ;D

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Re: AudioBookSleep
« Reply #2 on: February 26, 2009, 04:50 PM »
 ;D I pass the buck to the Autohotkey devs. Clearly they need to add some more commands. After that we could just run this:
Loop
{
Sleep, 1000
IfExist Brain
 var := A_BrainState
if var = sleep
 Shutdown, 9
}
:D
« Last Edit: February 26, 2009, 04:53 PM by Nod5 »

Ampa

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 592
  • I am cute ;)
    • View Profile
    • MonkeyDash - 2 Player strategy boardgame
    • Donate to Member
Re: AudioBookSleep
« Reply #3 on: February 26, 2009, 04:54 PM »
Need not be a brain sensor - just a button that you hold down while you are awake. If you release the button a 3(?) minute countdown is triggered that stops the book, unless of course you press the button again.

In the first instance it could just be a key on your laptop, but ultimately I think you'll need to go into production of buttons on the end of a USB cable,  then bluetooth buttons, wi-fi enabled buttons etc.

Ampa

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: AudioBookSleep
« Reply #4 on: February 26, 2009, 05:02 PM »
ultimately I think you'll need to go into production of buttons on the end of a USB cable,  then bluetooth buttons, wi-fi enabled buttons etc.
And if all those buttons aren't enough, don't forget to zip up the code.


edit: can't proof read properly

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: AudioBookSleep
« Reply #5 on: February 26, 2009, 06:07 PM »
yep, there are definitely a lot of places in the computing world where a "dead man's switch" can be of use.

Speaking for myself, I like to see some series/movies when I go to sleep. It would be great to have such a switch handy. However it should be possible for some piece of software to override this switch, for example when you're downloading something.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Re: AudioBookSleep
« Reply #6 on: February 27, 2009, 12:05 PM »
AudioBookSleep v090227
http://nod5.dcmember.../audiobooksleep.html

overview:
AudioBookSleep waits X minutes, saves a screenshot of VLC to desktop, then shuts down the computer.
The VLC screenshot shows the filename and time just before shutdown.
That 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 later chapters that gives away the plot! You wish for some automatic screenshot-then-shutdown timer. So you start to use AudioBookSleep.

audiobooksleep.png
« Last Edit: February 28, 2009, 03:01 AM by Nod5 »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: AudioBookSleep
« Reply #7 on: March 17, 2009, 05:35 PM »
Cool.
Written up in ghacks today: http://www.ghacks.ne.../17/audiobook-sleep/

ps. feel free to bundle minicap.exe in with your zip if you like.


Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Re: AudioBookSleep
« Reply #8 on: March 19, 2009, 05:02 PM »
Great! ghacks is a cool place!

AudioBookSleep v090319b
http://nod5.dcmember.../audiobooksleep.html
090319: if a VLC window is not found then the entire desktop (=all active screens) is screencapped instead
090319b: fixed a pathbug, bundled minicap.exe (thanks and cheers to mouser!)