+ 3

Can one write a code in to detect if a laptop battery is full??

23rd Aug 2017, 10:01 PM
Eli Baraka
Eli Baraka - avatar
3 Respostas
+ 11
Yes, of course. In Python you can use the 'power' module: https://pypi.python.org/pypi/power/1.4
23rd Aug 2017, 10:08 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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; }
24th Aug 2017, 1:26 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar