With our new insight into hooking SystemInformation is JScript, this simplifies the setup greatly, which what I was originally hoping to achieve.
##JScript
Either of these functions should do the job - just pick one …
##NET [net] (Script)##
| Script Name: | NET |
| Script Handler: | net |
Script:
function battLevel(){
var m = host.lib("System.Windows.Forms");
var p = m.System.Windows.Forms.SystemInformation.PowerStatus;
return (p.BatteryLifePercent * 100).toFixed(0);
}
function battLevel2(){
var m = host.type("System.Windows.Forms.SystemInformation","System.Windows.Forms");
return (m.PowerStatus.BatteryLifePercent * 100).toFixed(0);
}
##Trigger to control frequency of Battery Level check
Choose 1 of these, or make your own.
##Action to store Battery Level
##BATT Store Level [Update Program Setting] (Action)##
| Action Name: | BATT Store Level |
| Action Type: | Update Program Setting |
###Parameters:###
| Setting Name: | [:settingName] |
| Setting Value: | [:settingValue] |
| Update Type: | Update |
| Is Local: | True |
##Action to Execute Automation Command
We need this so we can run the JScript as a background Task.
##BATT ExecAMC [Execute Automation Command] (Action)##
| Action Name: | BATT ExecAMC |
| Action Type: | Execute Automation Command |
###Parameters:###
| Automation Command Name: | [:AMCname] |
| Command Value: | [:AMCvalue] |
| Background: | [:runBG] |
| Delay: | [:delay] |
##Action to update Application Subtitle …
##AST Update Application Subtitle [Update Application Subtitle] (Action)##
| Action Name: | AST Update Application Subtitle |
| Action Type: | Update Application Subtitle |
###Parameters:###
| Title Location: | Shell Header |
| Title: | [:content] |
| Background: | [:bg] |
| Height: | [:height] |
| Refresh Asnyc: | [:refreshAsync] |
##Rule to capture Trigger
##BATT Trigger [Trigger Executed] (Rule)##
| Rule Name: | BATT Trigger |
| Event Name: | Trigger Executed |
| Rule Tags: | |
Custom Constraint List (1):
Trigger Name | Equals | BATT Trigger |
##Actions (1):##
BATT ExecAMC
Constraint: (none)
| AMCname: | BATT Update |
| AMCvalue: | |
| runBG: | True |
| delay: | 0 |
##Mappings##
| Terminal | User Role | Department | Ticket Type |
* | * | * | * |
##Rule to handle Automation Command and update Subtitle …
##BATT Update [Automation Command Executed] (Rule)##
| Rule Name: | BATT Update |
| Event Name: | Automation Command Executed |
| Rule Tags: | |
Custom Constraint List (1):
Automation Command Name | Equals | BATT Update |
##Actions (2):##
BATT Store Level
Constraint: (none)
| settingName: | BatteryLevel |
| settingValue: | {CALL:pshell.batt()} |
AST Update Application Subtitle
Constraint: (none)
| content: |
(see below)
|
| bg: | |
| height: | |
| refreshAsync: | |
content:
<size 18><font Consolas><color Yellow>BATT:{SETTING:BatteryLevel}%</color></font></size>
##Mappings##
| Terminal | User Role | Department | Ticket Type |
* | * | * | * |