Hoşgeldin Misafir

Batarya Yuzdesi Trackeri

MiRaT

13 Kas 2017
2,077 Mesaj

Aktiflik

Seviye

Deneyim

TIM / GÖREV:
Kod:
Kod yazarken oyun oynarken vs batarya durumunu kontrol etmeyi unutuyorum ve bu konuda takintili bir insanim, %100e gelince cikartmam lazim.
O yuzden bu kucuk sirin seyi yazdim.


Kod:
#include <iostream>
#include <windows.h>
#include <sstream>

//message box
template<typename T>
vo id alert(T item){
 	std::ostringstream os;
	os<<item;
	MessageBoxA(NULL, os.str().c_str(), "Reminder!", MB_OK | MB_ICONINFORMATION);
}

//Getting the battery lvl
int getBatteryLevel(){
    SYSTEM_POWER_STATUS status;
    GetSystemPowerStatus(&status);
    return status.BatteryLifePercent;
}

int main(){
	static std::string t = "Batarya \% 100";
	//Actually I'm not sure about this implementation. Gonna try to improve this.
	while(true){
	int x = getBatteryLevel();
		if(x == 100){
			alert(t);
			break;
		}else{
			Sleep(20 * 60000);
		}
	}
	return 0;
}