Sign in to follow this  
Followers 0
gift8188

how to know the notebook using battery?

8 posts in this topic

#1 ·  Posted (edited)

hello!

how to know the notebook using battery?

Thank you~~~

Edited by SmOke_N
Changed spelling in title

Share this post


Link to post
Share on other sites



notekook ? What's that ?

oh,sorry,it made a mistake.

it is notebook

Share this post


Link to post
Share on other sites

Something like this maybe?

$structSystemPowerStatus = DllStructCreate("byte ACLineStatus; byte BatteryFlag; byte BatteryLifePercent; byte Reserved1; dword BatteryLifeTime; dword BatteryFullLifeTime")
$ret = DllCall("kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($structSystemPowerStatus))
If @error Then Exit
If $ret <> 0 Then
    $nOnBattery   = DllStructGetData($structSystemPowerStatus,  "ACLineStatus")
    $nBatteryLife = DllStructGetData($structSystemPowerStatus,  "BatteryLifePercent")
    If $nOnBattery == 0 Then
        MsgBox(48, @ScriptName, "Running on battery. Percentage = " & $nBatteryLife)
    Else
        MsgBox(48, @ScriptName, "Running on AC-power")
    EndIf
EndIf

Share this post


Link to post
Share on other sites

Something like this maybe?

$structSystemPowerStatus = DllStructCreate("byte ACLineStatus; byte BatteryFlag; byte BatteryLifePercent; byte Reserved1; dword BatteryLifeTime; dword BatteryFullLifeTime")
$ret = DllCall("kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($structSystemPowerStatus))
If @error Then Exit
If $ret <> 0 Then
    $nOnBattery   = DllStructGetData($structSystemPowerStatus,  "ACLineStatus")
    $nBatteryLife = DllStructGetData($structSystemPowerStatus,  "BatteryLifePercent")
    If $nOnBattery == 0 Then
        MsgBox(48, @ScriptName, "Running on battery. Percentage = " & $nBatteryLife)
    Else
        MsgBox(48, @ScriptName, "Running on AC-power")
    EndIf
EndIf
thanks~~~

Share this post


Link to post
Share on other sites

I was also looking for a way to make a power meter. I didn't find anything on the forums but stumbled on this on my own. I'm posting this on the posts that were talking about power meters.

This works on my Compaq running XP. It will import even it the window is hidden. I do have the icon set to always show in the taskbar. $power1 imports the words Batteries or AC Power and $power2 imports the battery life in percent.

$power1 = ControlGetText("Power Meter", "", "Static6")
 $power2 = ControlGetText("Power Meter", "", "Static8")
 msgbox (0,"", $power1 & "  " & $power2)

Share this post


Link to post
Share on other sites

Something like this maybe?

$structSystemPowerStatus = DllStructCreate("byte ACLineStatus; byte BatteryFlag; byte BatteryLifePercent; byte Reserved1; dword BatteryLifeTime; dword BatteryFullLifeTime")
$ret = DllCall("kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($structSystemPowerStatus))
If @error Then Exit
If $ret <> 0 Then
    $nOnBattery   = DllStructGetData($structSystemPowerStatus,  "ACLineStatus")
    $nBatteryLife = DllStructGetData($structSystemPowerStatus,  "BatteryLifePercent")
    If $nOnBattery == 0 Then
        MsgBox(48, @ScriptName, "Running on battery. Percentage = " & $nBatteryLife)
    Else
        MsgBox(48, @ScriptName, "Running on AC-power")
    EndIf
EndIf

Awsome! Just what I needed to complete my project! Thanks for posting this :)

Share this post


Link to post
Share on other sites
I changed it a bit, to make it comfortable for German Users:
$structSystemPowerStatus = DllStructCreate("byte ACLineStatus; byte BatteryFlag; byte BatteryLifePercent; byte Reserved1; dword BatteryLifeTime; dword BatteryFullLifeTime")
$x = 0
$p = 100
    While 1
    $ret = DllCall("kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($structSystemPowerStatus))
    $nOnBattery   = DllStructGetData($structSystemPowerStatus,  "ACLineStatus")
    $nBatteryLife = DllStructGetData($structSystemPowerStatus,  "BatteryLifePercent")
    If $nBatteryLife < $p -5 Then
         MsgBox(48, "Batterie Status", "Der Akku ist nur noch zu "&$nBatteryLife&"% gefüllt!")
         $p = $nBatteryLife
    EndIf
    If $nOnBattery == 0 Then
        If $x = 1 Or $x = 0  Then
        MsgBox(48, "Nicht angeschlossen!", "Der Computer ist nicht angeschlossen, und läuft über den Akku. ("&$nBatteryLife&"%)")
        $x = 2
        EndIf
    Else
        If $x = 2 Or $x = 0 Then
        MsgBox(48, "Angeschlossen!", "Der Computer ist angeschlossen. ("&$nBatteryLife&"%)")
        $x = 1
        EndIf
    EndIf
    WEnd

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