Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-05-2007, 06:36 PM
Senior Member
 
Join Date: Nov 2007
Posts: 128
Default Use vbscript to get battery info then send to variable in swfkit?

How would I do this? Here is the vbscript:

Code:
Private Sub UpdatePowerInfo()
  Dim ps As PowerStatus = SystemInformation.PowerStatus

  ' Charging, discharging, full, etc.
  BatteryChargeStatusTextBox.Text = ps.BatteryChargeStatus.ToString()

  ' .1 - 0 for current battery charge
  BatteryLifePercentTextBox.Text = (ps.BatteryLifePercent * 100) & "%"
  PowerLineStatusTextBox.Text = ps.PowerLineStatus.ToString()

  ' How long is battery life based on current charge
  Dim ts As New TimeSpan(0, 0, ps.BatteryLifeRemaining)

  If ps.BatteryLifeRemaining > 0 Then
    BatteryLifeRemainingTextBox.Text = ts.ToString()
  Else
    BatteryLifeRemainingTextBox.Text = "Unknown"
  End If

  ' How long is battery life if fully charged (seconds)
  ts = New TimeSpan(0, 0, ps.BatteryFullLifetime)

  If ps.BatteryFullLifetime > 0 Then
    BatteryFullLifetimeTextBox.Text = ts.ToString()
  Else
    BatteryFullLifetimeTextBox.Text = "Unknown"
  End If

  ' PowerLineStatus is Online (AC), Offline (Battery), or Unknown
  PowerModeToolStripStatusLabel.Text = _
  IIf(ps.PowerLineStatus = PowerLineStatus.Online, "AC", "Battery")

End Sub

Visual C#

private void UpdatePowerInfo()
{
  PowerStatus ps = SystemInformation.PowerStatus;
  // Charging, discharging, full, etc.
  BatteryChargeStatusTextBox.Text 
    = ps.BatteryChargeStatus.ToString();

  // .1 - 0 for current battery charge
  BatteryLifePercentTextBox.Text 
    = (ps.BatteryLifePercent * 100) + "%";
  PowerLineStatusTextBox.Text = ps.PowerLineStatus.ToString();

  // How long is battery life based on current charge
  TimeSpan ts = new TimeSpan(0, 0, ps.BatteryLifeRemaining);

  if (ps.BatteryLifeRemaining > 0)
    BatteryLifeRemainingTextBox.Text = ts.ToString();
  else
    BatteryLifeRemainingTextBox.Text = "Unknown";

  // How long is battery life if fully charged (seconds)
  ts = new TimeSpan(0, 0, ps.BatteryFullLifetime);
  if (ps.BatteryFullLifetime > 0)
    BatteryFullLifetimeTextBox.Text = ts.ToString();
  else 
    BatteryFullLifetimeTextBox.Text = "Unknown";

  // PowerLineStatus is Online (AC), Offline (Battery), or Unknown
  PowerModeToolStripStatusLabel.Text = 
    ((ps.PowerLineStatus == PowerLineStatus.Online) 
    ? "AC" : "Battery");

}
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:41 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.