[Tutor] Writing Python Script to read battery level

python at bdurham.com python at bdurham.com
Mon Jan 17 12:02:50 CET 2011


FT,

> Is there a way to read the battery level using Python?

Check out the following code snippet:

Get info on power/battery status
http://nullege.com/codes/show/src@jaraco.windows-1.6@jaraco@windows@power.py/14/ctypes.wintypes.BOOL

This code snippet requires the following 3rd party packages:

1. Mark Hammond's pywin32 (comes bundled with ActiveState versions of
Python)
https://sourceforge.net/projects/pywin32/

2. Tim Golden's wmi (requires pywin32)
http://timgolden.me.uk/python/wmi.html 

There's also a Python mailing list dedicated to Windows API questions:
http://mail.python.org/mailman/listinfo/python-win32

Good luck!

Malcolm


More information about the Tutor mailing list