+ 3
Can one write a code in to detect if a laptop battery is full??
3 Answers
+ 11
Yes, of course.
In Python you can use the 'power' module:
https://pypi.python.org/pypi/power/1.4
+ 7
A C++ Win32 Version:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
SYSTEM_POWER_STATUS spsPwr;
if( GetSystemPowerStatus(&spsPwr) )
{
cout << "\nAC Status : " << static_cast<double>(spsPwr.ACLineStatus);
cout<<"\nBattery Status : " << static_cast<double>(spsPwr.BatteryFlag);
cout<<"\nBattery Life % : " << static_cast<double>(spsPwr.BatteryLifePercent);
return 0;
}
else
return 1;
}