×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Access tablet battery status
2

Access tablet battery status

Access tablet battery status

(OP)
I have a VP9 application running on a windows tablet that runs full screen including hiding the task bar.
I would like to access the battery life information so I can display the info in the application.

Anyone know how that can be done?

Alastair

RE: Access tablet battery status

2
Alastair,

Check the Win32_Battery class at https://docs.microsoft.com/en-us/windows/desktop/c....

A sample usage:

CODE --> VFP

CLEAR

LOCAL BStatus AS String

TEXT TO m.BStatus NOSHOW
:1:Discharging:
:2:Connected to AC:
:3:Fully charged:
:4:Low:
:5:Critical:
:6:Charging:
:7:Charging and high:
:8:Charging and low:
:9:Charging and critical:
:10:Undefined:
:11:Partially charged:
ENDTEXT

LOCAL WMIService, AllBatteries, Battery

m.WMIService = GETOBJECT("winmgmts:\\.\root\cimv2")

m.AllBatteries = m.WMIService.ExecQuery("SELECT * FROM Win32_Battery",,48)

FOR EACH m.Battery IN m.AllBatteries

	? "Battery status:", STREXTRACT(m.BStatus, TEXTMERGE(":<<m.Battery.BatteryStatus>>:"), ":")
	? "Charged at", TRANSFORM(m.Battery.EstimatedChargeRemaining), "%"

ENDFOR 

RE: Access tablet battery status

(OP)
Thanks! I will take a look at this.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close