• Offizieller Beitrag

    Wenn Anwendungen auf einem Notebook laufen, sollte man evtl. auch den Ladezustand der Akkus im Auge behalten und entsprechend reagieren (Warnmeldung, Abbruch etc.).
    Einige Infos lassen sich mit AutoIt-Scriptomatic über "ROOT\CIMV2" - "Win32_Battery" erhalten.

    Ich hab hier mal zusammengestellt, was über die WMI-Klassen in der "ROOT\WMI" zu erhalten ist.

    Spoiler anzeigen
    [autoit]

    $str = ''
    $strComputer = "."
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\WMI")
    $colItems = $objWMIService.ExecQuery( _
    "SELECT * FROM BatteryFullChargedCapacity")
    $str = "-----------------------------------" & @LF & _
    "BatteryFullChargedCapacity instance" & @LF & _
    "-----------------------------------" & @LF
    $count = 1
    For $objItem In $colItems
    $str &= $count & '. ' & "Max. Ladekapazität: " & $objItem.FullChargedCapacity & @LF
    $count += 1
    Next
    $str &= @LF
    $colItems = $objWMIService.ExecQuery( _
    "SELECT * FROM BatteryRuntime")
    $str &= "-----------------------------------" & @LF & _
    "BatteryRuntime instance" & @LF & _
    "-----------------------------------" & @LF
    $count = 1
    For $objItem In $colItems
    $str &= $count & '. ' & "Restlaufzeit: " & $objItem.EstimatedRuntime & @LF
    $count += 1
    Next
    $str &= @LF
    $colItems = $objWMIService.ExecQuery( _
    "SELECT * FROM BatteryStatus")
    $str &= "-----------------------------------" & @LF & _
    "BatteryStatus instance" & @LF & _
    "-----------------------------------" & @LF
    $count = 1
    For $objItem In $colItems
    $str &= $count & '. ' & "Critical: " & $objItem.Critical & @LF ; Ladezustand kritisch: True(-1)/False(0)
    $str &= $count & '. ' & "Charging: " & $objItem.Charging & @LF ; Laden: True(-1)/False(0)
    $str &= $count & '. ' & "ChargeRate: " & $objItem.ChargeRate & @LF ; Ladetempo: Number
    $str &= $count & '. ' & "Discharging: " & $objItem.Discharging & @LF ; Entladen: True(-1)/False(0)
    $str &= $count & '. ' & "DischargeRate: " & $objItem.DischargeRate & @LF ; Entladetempo: Number
    $str &= $count & '. ' & "Voltage: " & $objItem.Voltage & @LF ; 1-Akkubetrieb, 2-Netzbetrieb
    $count += 1
    Next

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0, 'Akku Info', $str)

    [/autoit]
    • Offizieller Beitrag

    Hi,

    paßt zu

    Spoiler anzeigen
    [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    If IsObj($colItems) then
    For $objItem In $colItems
    $Output = $Output & "BatteryRechargeTime: " & $objItem.BatteryRechargeTime & @CRLF
    $Output = $Output & "BatteryStatus: " & $objItem.BatteryStatus & @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 & "Status: " & $objItem.Status & @CRLF
    $Output = $Output & "TimeToFullCharge: " & $objItem.TimeToFullCharge & @CRLF
    Next
    ConsoleWrite($Output)
    Else
    Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Battery" )
    Endif

    [/autoit]

    So long,

    Mega

    • Offizieller Beitrag

    Hi,

    dies hätte ich noch :

    Spoiler anzeigen
    [autoit]


    $SYSTEM_POWER_STATUS = DllStructCreate("byte;byte;byte;byte;int;int")

    [/autoit] [autoit][/autoit] [autoit]

    $test = DllCall("kernel32.dll", "int", "GetSystemPowerStatus", _
    "ptr", DllStructGetPtr($SYSTEM_POWER_STATUS))

    [/autoit] [autoit][/autoit] [autoit]

    If $test[0] Then
    MsgBox(4096, "", DllStructGetData($SYSTEM_POWER_STATUS, 1))
    MsgBox(4096, "", DllStructGetData($SYSTEM_POWER_STATUS, 3))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    #cs
    SYSTEM_POWER_STATUS

    Contains information about the power status of the system.

    typedef struct _SYSTEM_POWER_STATUS {
    BYTE ACLineStatus;
    BYTE BatteryFlag;
    BYTE BatteryLifePercent;
    BYTE Reserved1;
    DWORD BatteryLifeTime;
    DWORD BatteryFullLifeTime;
    } SYSTEM_POWER_STATUS,
    *LPSYSTEM_POWER_STATUS;

    Members

    ACLineStatus
    The AC power status. This member can be one of the following values.
    Value Meaning
    0 Offline
    1 Online
    255 Unknown status
    BatteryFlag
    The battery charge status. This member can contain one or more of the following flags.
    Value Meaning
    1 High—the battery capacity is at more than 66 percent
    2 Low—the battery capacity is at less than 33 percent
    4 Critical—the battery capacity is at less than five percent
    8 Charging
    128 No system battery
    255 Unknown status—unable to read the battery flag information

    The value is zero if the battery is not being charged and the battery capacity is between low and high.
    BatteryLifePercent
    The percentage of full battery charge remaining. This member can be a value in the range 0 to 100, or 255 if status is unknown.
    Reserved1
    Reserved; must be zero.
    BatteryLifeTime
    The number of seconds of battery life remaining, or –1 if remaining seconds are unknown.
    BatteryFullLifeTime
    The number of seconds of battery life when at full charge, or –1 if full battery lifetime is unknown.
    #ce

    [/autoit]

    So long,

    Mega