dickep Posted March 28, 2008 Share Posted March 28, 2008 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 Link to comment Share on other sites More sharing options...
weaponx Posted March 28, 2008 Share Posted March 28, 2008 (edited) I'm suggesting that you make your own power meter using info retrieved from WMI. expandcollapse popup; 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 March 28, 2008 by weaponx Link to comment Share on other sites More sharing options...
weaponx Posted March 28, 2008 Share Posted March 28, 2008 Maybe this will work with a laptop battery: expandcollapse popup; 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 Link to comment Share on other sites More sharing options...
dickep Posted March 28, 2008 Author Share Posted March 28, 2008 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 Link to comment Share on other sites More sharing options...
weaponx Posted March 28, 2008 Share Posted March 28, 2008 Well I know you can launch the Power Config control panel like this:Run("control powercfg.cpl")Also here is a link to antoher power meter option:http://mattcollinge.wordpress.com/software/power-meter-plus/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now