The following code reads the status of a notebook battery:
B4X:
Sub Globals
'Declare the global variables here.
End Sub
Sub App_Start
obj.New1(False)
obj.CreateNew("System.Windows.Forms.SystemInformation" & obj.System_Windows_Forms)
obj.Value = obj.GetProperty("PowerStatus")
Msgbox(FindPowerLineStatus, FindBatteryLifePercent)
End Sub
Sub FindBatteryLifePercent
Return obj.GetProperty("BatteryLifePercent")
End Sub
Sub FindPowerLineStatus
Return obj.GetProperty("PowerLineStatus") 'returns Offline or Online
End Sub