Sign in to follow this  
Followers 0
dickep

Windows Power Meter

5 posts in this topic

OK, I am getting senile!!!

I want to open the Windows Power Meter from the Task Tray (not the whole Power Options window with all the tabs).

Thanks.

E

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm suggesting that you make your own power meter using info retrieved from WMI.

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Battery", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "Availability: " & $objItem.Availability & @CRLF
      $Output = $Output & "BatteryRechargeTime: " & $objItem.BatteryRechargeTime & @CRLF
      $Output = $Output & "BatteryStatus: " & $objItem.BatteryStatus & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "Chemistry: " & $objItem.Chemistry & @CRLF
      $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
      $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
      $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "DesignCapacity: " & $objItem.DesignCapacity & @CRLF
      $Output = $Output & "DesignVoltage: " & $objItem.DesignVoltage & @CRLF
      $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF
      $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
      $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
      $Output = $Output & "EstimatedChargeRemaining: " & $objItem.EstimatedChargeRemaining & @CRLF
      $Output = $Output & "EstimatedRunTime: " & $objItem.EstimatedRunTime & @CRLF
      $Output = $Output & "ExpectedBatteryLife: " & $objItem.ExpectedBatteryLife & @CRLF
      $Output = $Output & "ExpectedLife: " & $objItem.ExpectedLife & @CRLF
      $Output = $Output & "FullChargeCapacity: " & $objItem.FullChargeCapacity & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
      $Output = $Output & "MaxRechargeTime: " & $objItem.MaxRechargeTime & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
      $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
      $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
      $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
      $Output = $Output & "SmartBatteryVersion: " & $objItem.SmartBatteryVersion & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF
      $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
      $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF
      $Output = $Output & "TimeOnBattery: " & $objItem.TimeOnBattery & @CRLF
      $Output = $Output & "TimeToFullCharge: " & $objItem.TimeToFullCharge & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Battery" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

EDIT: After testing, it looks like this may be grabbing info from my UPS battery backup, i'm not sure how it will work on a laptop.

Edited by weaponx

Share this post


Link to post
Share on other sites

Maybe this will work with a laptop battery:

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PortableBattery", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "Availability: " & $objItem.Availability & @CRLF
      $Output = $Output & "BatteryStatus: " & $objItem.BatteryStatus & @CRLF
      $Output = $Output & "CapacityMultiplier: " & $objItem.CapacityMultiplier & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "Chemistry: " & $objItem.Chemistry & @CRLF
      $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
      $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
      $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "DesignCapacity: " & $objItem.DesignCapacity & @CRLF
      $Output = $Output & "DesignVoltage: " & $objItem.DesignVoltage & @CRLF
      $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF
      $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
      $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
      $Output = $Output & "EstimatedChargeRemaining: " & $objItem.EstimatedChargeRemaining & @CRLF
      $Output = $Output & "EstimatedRunTime: " & $objItem.EstimatedRunTime & @CRLF
      $Output = $Output & "ExpectedLife: " & $objItem.ExpectedLife & @CRLF
      $Output = $Output & "FullChargeCapacity: " & $objItem.FullChargeCapacity & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
      $Output = $Output & "Location: " & $objItem.Location & @CRLF
      $Output = $Output & "ManufactureDate: " & $objItem.ManufactureDate & @CRLF
      $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF
      $Output = $Output & "MaxBatteryError: " & $objItem.MaxBatteryError & @CRLF
      $Output = $Output & "MaxRechargeTime: " & $objItem.MaxRechargeTime & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
      $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
      $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
      $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
      $Output = $Output & "SmartBatteryVersion: " & $objItem.SmartBatteryVersion & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF
      $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
      $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF
      $Output = $Output & "TimeOnBattery: " & $objItem.TimeOnBattery & @CRLF
      $Output = $Output & "TimeToFullCharge: " & $objItem.TimeToFullCharge & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_PortableBattery" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

Share this post


Link to post
Share on other sites

Actually, I have. BUT.... Microsoft has a "bug" in their Power Meter application and I am trying to test out if the reporting of the battery charge gas gauge is OK or not. I need to have this test for some apps I have to write. I will compare some values that are reported by both.

So, still need to just make sure how to open the Power Meter applet.

Thanks

E

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0