I have a python file as battery_perc.pyw:
import subprocess
import time
import pyttsx3
engine = pyttsx3.init()
def say_pc(txt):
engine.say(txt)
engine.runAndWait()
while True:
say_pc(str(int(subprocess.run(["WMIC", "PATH", "Win32_Battery", "Get", "EstimatedChargeRemaining"], capture_output=True).stdout.decode().split("\n")[1][:3].strip())))
time.sleep(10)
I created exe
file using below:
pyinstaller --onefile --noconsole 'battery_perc.pyw'
When I am running the battery_perc.exe, it works but every 10 seconds WMI Console is opened and closed immediately, just like its blinking.