DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Laptop Battery.  (Read 9,825 times)

jrmelb

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 7
Laptop Battery.
« on: January 04, 2014, 06:29 AM »
Is there any software that will alert you to the power cord being disconnected from a laptop and/or to the battery reaching low levels.

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: Laptop Battery.
« Reply #1 on: January 04, 2014, 07:39 AM »
Windows will alert you when your battery gets low, first will be a warning, then there'll be a critical alert, followed by standby, hibernation, or shutdown (depends on how you have it configured).

Control Panel->Power Options

Untitled.png
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 11,970
    • Gathering Badge
    • Participated in NANY Challenge Once
Re: Laptop Battery.
« Reply #2 on: January 04, 2014, 10:04 AM »
Not a direct solution, but works for me - I have different screen-brightness settings for battery and electricity.

In Win8 I get a full screen banner when the battery is down to 10%. But have a good look around the power options as 4wd suggests.
Tom

Innuendo

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 2,266
Re: Laptop Battery.
« Reply #3 on: January 04, 2014, 06:09 PM »
Isn't there usually an icon down in the system tray that shows whether you are on AC or battery?

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 11,970
    • Gathering Badge
    • Participated in NANY Challenge Once
Re: Laptop Battery.
« Reply #4 on: January 04, 2014, 08:33 PM »
Isn't there usually an icon down in the system tray that shows whether you are on AC or battery?

It doesnt notify of the change though (power => battery).


FWIW just discovered it is a convenient way of getting to the power options though, via right-click.
Tom

Vurbal

  • Mostly harmless
  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 653
    • Writer
Re: Laptop Battery.
« Reply #5 on: January 04, 2014, 09:15 PM »
Isn't there usually an icon down in the system tray that shows whether you are on AC or battery?

It doesnt notify of the change though (power => battery).

The icon always changed on my old WinXP laptops.
I learned to say the pledge of allegiance
Before they beat me bloody down at the station
They haven't got a word out of me since
I got a billion years probation
- The MC5

Follow the path of the unsafe, independent thinker. Expose your ideas to the danger of controversy. Speak your mind and fear less the label of ''crackpot'' than the stigma of conformity.
- Thomas J. Watson, Sr

It's not rocket surgery.
- Me


I recommend reading through my Bio before responding to any of my posts. It could save both of us a lot of time and frustration.

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 11,970
    • Gathering Badge
    • Participated in NANY Challenge Once
Re: Laptop Battery.
« Reply #6 on: January 04, 2014, 09:40 PM »
^ yeah, sorry, I wasnt clear there: I meant no notification in a more in your face manner, e.g. popup. Taskbar on autohide here doesnt help either, but I dont know how the OP (who's looking for this) works, so that may be the solution.
Tom

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: Laptop Battery.
« Reply #7 on: January 05, 2014, 12:30 AM »
Knowing what OS the OP is talking about would go a long way towards suggesting anything.
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

jrmelb

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 7
Re: Laptop Battery.
« Reply #8 on: January 05, 2014, 04:49 AM »
Yes - the OS is Windows 7.

:)

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: Laptop Battery.
« Reply #9 on: January 05, 2014, 05:49 AM »
YTOTPC* - Pretty boring, any time there's a power state change it'll pop up a message box.  This could be connecting or disconnecting AC power.

Code: (autoit)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;--- Tray Menu ---
Opt('TrayMenuMode', 3)
TraySetClick(16)
$exititem = TrayCreateItem('Exit')


; WMI object creation for CIMV2 namespace
$gobjWMI_CIMV2 = ObjGet("winmgmts:\\.\root\cimv2")

; WMI event notification sink for power management
$gobjWMI_PowerEVT_Sink = ObjCreate("WbemScripting.SWbemSink")
ObjEvent($gobjWMI_PowerEVT_Sink, "PowerEVT_SINK_")


; Build notifier object for power management events
$gobjWMI_CIMV2.ExecNotificationQueryAsync($gobjWMI_PowerEVT_Sink, "Select EventType from Win32_PowerManagementEvent")


;; Sleep forevAr - make sure to build a hotkey somewhere to allow you to terminate this process...
While 1
	$nMsg = TrayGetMsg()
	Switch $nMsg
		Case $exititem
			Exit
		Case Else
	EndSwitch
	Sleep(100)
WEnd

; Power Management event sink function
Func PowerEVT_SINK_OnObjectReady($wmiObject, $wmiAsyncContext)
	$intEvent = $wmiObject.EventType

	Switch $intEvent
		Case 4
			; Machine is entering suspend")
		Case 7
			; OS reports resume from suspend is complete")
		Case 10
			; AC <-> DC switch
			MsgBox(48, "YTOTPC", "Excuse me but you have suffered a AC/DC event." & @CRLF & @CRLF & "This could be because you tripped over the power cord" & @CRLF & "or inadvertently plugged it in.")
		Case 11
			; OEM Power event...
		Case 18
			; Hardware triggered resume from suspend...
		Case Else
			; You can case these out from the constant defines mentioned earlier in this thread
	EndSwitch
EndFunc   ;==>PowerEVT_SINK_OnObjectReady





* You Tripped Over The Power Cord
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

Original address: https://www.donationcoder.com/forum/index.php?topic=36941.0