Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, re, datetime, time
- import winsound
- winsound.Beep( 1024, 1000 )
- time.sleep( 1 )
- winsound.Beep( 2048, 1000 )
- print( 'Ready' )
- while True:
- file = open( "D:/scripts/.gsBatteryLog.txt", "a" ); # Log file location
- output = os.popen( "wmic Path Win32_Battery Get EstimatedChargeRemaining /Value" ).read()
- percent = re.compile( r"[^0-9]", re.MULTILINE ).sub( "", output )
- msg = datetime.datetime.now().isoformat()[0:19] + " " + percent
- file.write( msg )
- file.write( "\n" )
- file.close()
- print( msg )
- if int( percent ) < 25:
- winsound.Beep( 1024, 1000 )
- elif int( percent ) > 90:
- winsound.Beep( 2048, 1000 )
- time.sleep( 300 )
- # Add shortcut `python.exe path\to\gsBatteryLog.py` to Start-up
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement