Klipfolio Dashboard API

Object Engines.Platform

Object
   |
   +--Klip
         |
         +--Engines
               |
               +--Engines.Platform

Advanced Feature Some of the functions of this object are only available in the licensed, commercial version of Klipfolio Dashboard. Contact Klipfolio for further details.

The Engines.Platform object enables a Klip to query the Windows Management Interface.

Klip Security Model

Using the API calls below requires Klipfolio Dashboard Developer Edition and having the XML <scriptmode>extended</scriptmode> within the Klip's <setup> block, as shown below.

   <setup>
     <scriptmode>
       extended
     </scriptmode>
   </setup>
 
In developer mode, select "Allow Blocked Script to Run" from the Klip's Developer Tools menu.

In order to use this object without the Developer Mode turned on, you must have your Klip digitally signed by Klipfolio Inc.

WMI Example:

The following Klip makes a call to WMI to monitor the current memory once a minute.
<klip>
   <identity>
      <title>
         API: WMI Interface
      </title>
   </identity>
   <locations>
      <icon>
         http://www.klipfolio.com/static/klips/klipfolio/sample_icon.png
      </icon>
      <banner>
         http://www.klipfolio.com/static/klips/klipfolio/sample_banner.png   
      </banner>
   </locations>
   <setup>
      <scriptmode>
         extended
      </scriptmode>
   </setup>

   	<messages>
      		<loading>
         		Getting Memory Usage...
      		</loading>
   	</messages>
   	
	<style>
		item { 
			type:item 
		}
		
		mempercent { 
			itemcol: 1;
			noterow:1; 
			label:"Percentage";
		}
		
		memused { 
			itemcol: 2;
			noterow:2; 
			label:"Used";
		}
		
		memtotal { 
			itemcol: 3;
			noterow:3; 
			label:"Available";
		}
	</style>
   
	<klipscript>
		<![CDATA[

function onLoad ()
{
	Items.savehistory = false;
	Items.canalert = false;
	Items.autoremove = false;
}

function getMemData ()
{
	var freekbytes = Engines.Platform.getAvailableKBytes ();
	var totalbytes = Engines.Platform.queryWMI ("SELECT * FROM Win32_PhysicalMemory", "Capacity");

	if (freekbytes.length && totalbytes.length)
	{
		var memarray = totalbytes.split (",");

		var i;
		var totalkbytes = 0;
		for (i = 0; i < memarray.length; i++)
		{
			totalkbytes += memarray[i] - 0;
		}
		totalkbytes = totalkbytes / 1024;

		var mempct = Math.round ((totalkbytes - freekbytes)/ totalkbytes * 100);

		var xml = "<item><mempercent>" + mempct + "%</membercent>" +
			  "<memused>" + (totalkbytes - freekbytes) + " KB" + 
			  "</memused><memtotal>" + freekbytes + " KB" +
			  "</memtotal></item>"; 

		Items.clear( true );
		Engines.Data.process (xml);
	}

	return true;
}

function onRefresh ()
{
	var success = getMemData();
	
	// Make sure the user can't delete or dim (visit) the webcam image
	if(Items.length)
	{
		Items[0].canvisit = false;
		Items[0].candelete = false;
	}
	
	return success;
}

	]]>
	</klipscript>
</klip>
     	



 
Function Summary
 function getAvailableKBytes()
           Returns the number of available memory in KiloBytes.
 function getCPUUsage()
           Advanced Feature Returns the current CPU usage as a percentage.
 function getClipboardURL()
           Advanced Feature Gets the URL that is stored on the system's clipboard.
 function launchDefaultBrowser( <String> url )
           Advanced Feature Launches the system's default browser at the specified URL.
 function launchDefaultMailClient()
           Advanced Feature Launches the system's default e-mail client.
 function queryWMI( <String> query, <String> row )
           Advanced Feature Queries the contents of Windows Management Interface.

Function Detail

getAvailableKBytes

function getAvailableKBytes()

getCPUUsage

function getCPUUsage()

getClipboardURL

function getClipboardURL()

launchDefaultBrowser

function launchDefaultBrowser( <String> url )

launchDefaultMailClient

function launchDefaultMailClient()

queryWMI

function queryWMI( <String> query, <String> row )

Klipfolio Dashboard API

© 2011 Klipfolio Inc. All Rights Reserved.