topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Thursday March 28, 2024, 7:43 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: Alarm When Power Cord Falls Out of Notebook  (Read 17301 times)

Kruskal

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 72
    • View Profile
    • Donate to Member
Alarm When Power Cord Falls Out of Notebook
« on: May 22, 2007, 11:59 AM »
I'm looking for a utility that detects loss of power on a notebook PC and when it is reestablished.  I want a WAV file sounded in one case and ANOTHER WAV file in the other.  My BIOS will make an sound, but it is the same in both cases.

I think the trick is detecting the events.  Perhaps Windows Universal Power Supply support could be exploited.

Thanks -- Vincent

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: Alarm When Power Cord Falls Out of Notebook
« Reply #1 on: May 22, 2007, 12:03 PM »
I think this is a great idea.

Maybe even an option to change the background desktop color or image or something based on whether you are using battery or not, to help you remember?

Darwin

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,984
    • View Profile
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #2 on: May 22, 2007, 12:36 PM »
My Gateway (actually re-badged Samsung) Centrino notebook dims the screen to 25% when the AC cord is removed and restores it to 100% when AC is reconnected. However, I don't know how this is accomplished, as there is nothing in my Power options under the Control Panel to control it. At any rate, this is a very effective notifier and I quite miss it when I play around on my wife's Compaq, non-Centrino, notebook.
« Last Edit: May 22, 2007, 12:39 PM by Darwin »

nite_monkey

  • Member
  • Joined in 2006
  • **
  • Posts: 753
    • View Profile
    • Just Plain Super
    • Read more about this member.
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #3 on: May 22, 2007, 01:04 PM »
My Gateway (actually re-badged Samsung) Centrino notebook dims the screen to 25% when the AC cord is removed and restores it to 100% when AC is reconnected. However, I don't know how this is accomplished, as there is nothing in my Power options under the Control Panel to control it. At any rate, this is a very effective notifier and I quite miss it when I play around on my wife's Compaq, non-Centrino, notebook.
My brother's compaq does that also, though kruskal's idea would be good for all the computers that don't do that.
[Insert really cool signature here]

Kruskal

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 72
    • View Profile
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #4 on: May 22, 2007, 01:37 PM »
My Gateway (actually re-badged Samsung) Centrino notebook dims the screen to 25% when the AC cord is removed and restores it to 100% when AC is reconnected. However, I don't know how this is accomplished, as there is nothing in my Power options under the Control Panel to control it. At any rate, this is a very effective notifier and I quite miss it when I play around on my wife's Compaq, non-Centrino, notebook.
My brother's compaq does that also, though kruskal's idea would be good for all the computers that don't do that.
-nite_monkey (May 22, 2007, 01:04 PM)
In some situations, it is important for an audible alarm even if the screen makes the power state clear.  Often my notebook is closed and I hear the BIOS beep -- I have no idea if it is complaining that it lost power or is thanking me for restoring power.  For you see, on my notebook, at least, the power cord can appear to be plugged in when not actually making contact.

Thanks for all the comments -- Vincent

Darwin

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,984
    • View Profile
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #5 on: May 22, 2007, 04:36 PM »
I should have been more explicit - I was suggesting that the functionality that is built into my Gateway (and nitemonkey's brother's Compaq - it occurs to me that this might be an Intel vs. AMD thing, or a Centrino thing? as my wife's Compaq is an Athlon 64+) would be a great way to accomplish what Kruskal is after. I *think* that this must be a BIOS setting or an OS feature and not a software install and in my world it's always nice to accomplish these things without having to resort to installing anything.

I'm a complete dimwit when it comes to coding so I may be right out to lunch on this....

Laughing Man

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 105
  • V for Viktor
    • View Profile
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #6 on: May 25, 2007, 02:40 PM »
It's probably do your settings regarding battery life. I have three options to choose from, little power usage, balanced, and high performance. Which..they really don't change much but the screen brightness. So I leave my laptop on balanced. What happens when the power cable is plugged in, is the laptop detects that it's getting power so it switches it to high performance (hence my screen at full brightness).

Oh and I have a Centrino. To add any possible information.

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #7 on: May 27, 2007, 07:05 PM »
:) Here a simple command line utility.

BatteryRun - Run commands when the power plug is connected or disconnected.

Command line:
  BatteryRun.exe "<connect command>" "<disconnect command>"
Example:
  BatteryRun.exe "ding.wav" "calc.exe"

You'll find the downloads and more info at 1 Hour Software by Skrommel.

For multiple actions, I suggest making an AutoHotkey script.

Skrommel

Kruskal

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 72
    • View Profile
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #8 on: May 27, 2007, 10:11 PM »
:) Here a simple command line utility.

BatteryRun - Run commands when the power plug is connected or disconnected.

Command line:
  BatteryRun.exe "<connect command>" "<disconnect command>"
Example:
  BatteryRun.exe "ding.wav" "calc.exe"

You'll find the downloads and more info at 1 Hour Software by Skrommel.

For multiple actions, I suggest making an AutoHotkey script.

Skrommel

That's fantastic!  May I ask what the basic hook you used is?

I note that you left it as an exercise for the reader to figure out how to simply play a WAV file.  Putting the WAV file as a command, as you suggest, brings up the Media Player UI.  I found many discussions about how to simply play a WAV file from, say, a BAT file which concluded that you can't.  But one lead me to SNDREC32 used, I think, to make recordings.  SNDREC32 /PLAY /CLOSE /EMBEDDING Sound.WAV will simply play a sound -- no UI or other irrelevances.  It does take a long time to play -- I'd still like a simple and FAST WAV player.

So the entire Target of my BatteryRun shortcut is:

"C:\Program Files\Utilities\BatteryRun.exe" "C:\WINDOWS\system32\sndrec32.exe /play /close /embedding C:\WINDOWS\Media\tada.wav" "C:\WINDOWS\system32\sndrec32.exe /play /close /embedding C:\WINDOWS\Media\Windows XP Battery Critical.wav"

Thanks -- Vincent
« Last Edit: May 27, 2007, 11:26 PM by Kruskal »

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #9 on: May 28, 2007, 04:40 AM »
 :) It's kind of simple, I think it needs a proper options screen, but I only had an hour last night.

It uses GetSystemPowerStatus, so a lot more alarms can be added, like battery low, 70% recharged, or whatever.

I've added automatic WAV and MP3 detection to BatteryRun v1.1.

Skrommel

Kruskal

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 72
    • View Profile
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #10 on: May 28, 2007, 10:33 AM »
:) It's kind of simple, I think it needs a proper options screen, but I only had an hour last night.

It uses GetSystemPowerStatus, so a lot more alarms can be added, like battery low, 70% recharged, or whatever.

I've added automatic WAV and MP3 detection to BatteryRun v1.1.

Skrommel
It's much more responsive with the build-in WAV support -- thanks.  And has a more comprehensible call.

BTW the new BatteryRun does nothing with my old call.  I think it parses out the WAV extension and doesn't realize that it is an argument to the command to call. 

Personally, I feel no need for an options screen.  If you add one, it would be nice if everything could also be specified on the command line and, in that case, there would be no INI file.

Vincent
« Last Edit: May 28, 2007, 10:36 AM by Kruskal »

Kruskal

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 72
    • View Profile
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #11 on: May 29, 2007, 03:26 PM »
:) It's kind of simple, I think it needs a proper options screen, but I only had an hour last night.

It uses GetSystemPowerStatus, so a lot more alarms can be added, like battery low, 70% recharged, or whatever.

I've added automatic WAV and MP3 detection to BatteryRun v1.1.

Skrommel
I tried specifying an MP3 file and nothing sounded.

Vincent

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #12 on: May 29, 2007, 05:32 PM »
 :tellme: I haven't tried it, but according to the AutoHotkey manual:

All Windows OSes should be able to play .wav files. However, other files (.mp3, .avi, etc.) might not be playable if the right codecs or features aren't installed on the OS.

So what features could be missing?

Skrommel

Kruskal

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 72
    • View Profile
    • Donate to Member
Re: Alarm When Power Cord Falls Out of Notebook
« Reply #13 on: May 29, 2007, 07:05 PM »
:tellme: I haven't tried it, but according to the AutoHotkey manual:

All Windows OSes should be able to play .wav files. However, other files (.mp3, .avi, etc.) might not be playable if the right codecs or features aren't installed on the OS.

So what features could be missing?

Skrommel

I have no idea.  When I double-click on an MP3 file, RealPayer comes up and plays it.

Thanks -- Vincent