PROVISIO DevBlog

SiteRemote-Controlled Alert System for SiteKiosk Windows

The kiosk management solution SiteRemote can be used to create an alert message system for kiosk systems running SiteKiosk Windows. An alert message will overlay the default SiteKiosk user inferface informing users of special events. Note that the solution described in this blog post is intended as a sort of emergency system. If you just want to show changing information you should consider using SiteCaster.

Two files are needed on the SiteKiosk terminal. One is a JavaScript file (named alertswitch.js in this example) the second is an HTML file (named alert.html in this example). Both should be placed in a folder called alert that should be placed in the HTML folder of the SiteKiosk installation path.

Let's start with the alertswitch.js JavaScript file. The code of the file is as follows:

//Periodic event to check alert conditions every 25 seconds
//The lower this value the harder to use the local SiteKiosk escape menu to close SiteKiosk
SiteKiosk.Scheduler.AddPeriodicEvent(25000, CheckAlertValue);

//Shell object used to read the registry
var WshShell = new ActiveXObject("WScript.Shell");

//Global variable for the event id of the periodic alert text check
var PeriodicEventID = 0;

//Alert dialog properties
var gk_Emergency = SiteKiosk.SiteKioskUI.CreateHTMLDialog();
//Path to the html file used for the alert
gk_Emergency.URL = "file://" + SiteKiosk.SiteKioskDirectory + "Html\\Alert\\Alert.html";
gk_Emergency.TopMostWindow = true;
gk_Emergency.Closable = false;
gk_Emergency.Title = false;
gk_Emergency.Border = false;
gk_Emergency.Scrollbars = false;
gk_Emergency.Sysmenu = false;
gk_Emergency.CloseOnInput = false;
gk_Emergency.OnClose = onClose;
gk_Emergency.Maximize();

function CheckAlertValue(){
	try{
		//Check registry value !NOTE! The following registry path is for 64-Bit systems!
		if (WshShell.RegRead("HKLM\\SOFTWARE\\Wow6432Node\\PROVISIO\\SiteKiosk\\AlertValue") !== ""){
			//Resets the screensaver idle timeout to make sure the screensaver is not interfering with the alert
			SiteKiosk.ScreenSaver.Reactivate();
			//Show the alert
			gk_Emergency.ShowDialog();
			//Force hiding of the task bar during the alert (Note: Not required when running SiteKiosk in full screen mode)
			SiteKiosk.SiteSkin.TaskbarVisible = false;
		}
		else{
			if (PeriodicEventID !== 0)
			//Remove the periodic event that checks for alert text changes	
				SiteKiosk.Scheduler.RemoveEvent(PeriodicEventID);
			
			//Show the taskbar again (Note: Not required when running SiteKiosk in full screen mode)
			SiteKiosk.SiteSkin.TaskbarVisible = true;
			
			//Close the alert
			gk_Emergency.CloseDialog();
		}
			
	}
	catch(e){
		//No matching registry value, do nothing
	}
}

//Return the registry value to the alert dialog on request
function GetRegistryValue(){
    return WshShell.RegRead("HKLM\\SOFTWARE\\Wow6432Node\\PROVISIO\\SiteKiosk\\AlertValue");
}

//Allow the alert to write the event id of the periodic event that checks for alert text changes
function SetPeriodicEventID(evtid){
    PeriodicEventID = evtid;
}

function onClose(){
	if (PeriodicEventID !== 0)
	//Remove the periodic event that checks for alert text changes because dialog has been closed from outside of the script
		SiteKiosk.Scheduler.RemoveEvent(PeriodicEventID);
}

The file must be added to SiteKiosk as an external script file. This can be done in the configuration of SiteKiosk under Start Page & Browser -> Advanced. The file uses the AddPeriodicEvent method of the SiteKiosk Object Model to periodically check a registry value (in our example HKLM\\SOFTWARE\\Wow6432Node\\PROVISIO\\SiteKiosk\\AlertValue). The registry value is either an empty string or contains the alert text that should be displayed. If the check does not return an empty string, the ShowDialog method is used to show the dialog defined with the CreateHTMLDialog method. One of the properties of the dialog is the path to the alert.html file explained below in this document. If the alert is shown the taskbar of SiteKiosk is switched off (only required if no full screen mode is used) using the TaskbarVisible property. Additionally the SiteKiosk screensaver will be prevented during the display of the alert to minimize any possible interference with the alert message, which is why the Reactivate method is used. Once an empty string is detected in the registry the alert is switched off by means of the CloseDialog method.

The external script also contains two methods to provide the HTML file that displays the actual alert with the alert message (GetRegisryValue method) and to receive the event id of the periodic event used in the HTML file to check for changes in the alert text. The id is used to stop the periodic event once the alert message is no longer displayed with the help of the RemoveEvent method.

The alert.html HTML file that accompanies the external script is used to display the alert message. You might change the design of that page to whatever you like. The code of the HTML file is as follows:

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
	<style> 
	html { 
		background: red no-repeat center fixed; 
		background-size: cover;
	}
	body { 
		font-family: arial;
		text-align:center;
		font-size: 100px;
		color: white; 
	}
	div {
		margin-top: 15%;
		padding: 20px;
	}
	</style>
	</head>
	<body style="margin:0px;"> 
		<div id="Alert-Text">
			... 
		</div>
	</body>
	<script type="text/JScript">
		//Initialize the SiteKiosk Object Model
		window.external.InitScriptInterface();
		
		//Get the alert text from the external script
		function GetAlertValue(){
			document.getElementById("Alert-Text").innerHTML = SiteKiosk.ScriptDispatch.GetRegistryValue();
		}
		
		GetAlertValue();
		//Check the alert text every 5 seconds for changes
		var evtid = SiteKiosk.Scheduler.AddPeriodicEvent(5000, GetAlertValue);
		//Write event id to external script to remove event when closing the alert
		SiteKiosk.ScriptDispatch.SetPeriodicEventID(evtid);
	</script>
</html>

After the initialization of the SiteKiosk Object Model the ScriptDispatch object is used to retrieve the alert message from the external script. The AddPeriodicEvent method is used to periodically request the alert message to quickly react to changes. The id for that event is passed to the external script so that the event can be canelled once the alert is closed.

Note that the times for the periodic events in the script can be changed to your liking and the requirements of your environment.

With the two files required on the SiteKiosk terminal in place we can now focus on the SiteRemote part. Obviously the SiteKiosk terminal needs to be registered with a SiteRemote server. Within your SiteRemote team go to the SiteKiosk tab and select Jobs. Scroll all the way down and select New template. For the alert system to work we need at least two templates. One that switches the alert on and one to switch it off. The template that switches the alert on includes the string for the alert message. In case you have different predefined alert messages that you want to display with the alert system based on different situations, you can create different templates for each of the messages.

The create an ON template provide a job name, select SiteKiosk Windows as client type and Execute Script as action type. Click Add next to the selected action type and paste the following script into the script field. Make sure that you do not select the option Script requires SiteKiosk Object:

//ON !NOTE! The following registry path is for 64-Bit systems!
var gk_WshShell = new ActiveXObject("WScript.Shell");
gk_WshShell.RegWrite("HKLM\\SOFTWARE\\Wow6432Node\\PROVISIO\\SiteKiosk\\AlertValue", "Alert Text", "REG_SZ");

This will write the string Alert Text to the registry of a SiteKiosk terminal the job will be assigned to. Change the string to whatever you like and make as many different ON templates as you require. Note that you can also change the text each time you assign the job template to a machine.

The OFF template simply writes an empty string to the terminal's registry:

//OFF !NOTE! The following registry path is for 64-Bit systems!
var gk_WshShell = new ActiveXObject("WScript.Shell");
gk_WshShell.RegWrite("HKLM\\SOFTWARE\\Wow6432Node\\PROVISIO\\SiteKiosk\\AlertValue", "", "REG_SZ");

Each time you want to activate or deactivate an alert on one machine or a number of machines click one of the templates and assign it. If you assign the ON template from this example to a machine that runs the required files described above you will get an alert like this:

Note that for the alert message to be displayed, SiteKiosk must be running, which is the normal state on a SiteKiosk kiosk terminal.

Identifiying Individual SiteKiosk Windows Computers

Identifying individual SiteKiosk Windows computers can be helpful to deliver specific content to these machines. You can use either native JavaScript or the SiteKiosk Object Model to retrieve that information.

To use native JavaScript you need to enable the computer identification feature in the SiteKiosk configuration. When using the SiteKiosk Chrome Browser for example, you can find this feature under Start Page & Browser -> Chrome Browser -> Customize -> Settings -> Computer Identification. Tick the Add SiteKiosk to user agent header option and more importantly the Customize user agent field option.

You can leave the default value $(ComputerName) as this is exactly what we want to work with to identify the SiteKiosk Windows machine. That global variable will be replaced by the individual computer name automatically, so you do not need a separate configuration for each of your SiteKiosk computers. The additional information will be added at the end of the user agent string of the browser seperated by a semicolon.

For the Internet Explorer engine you will find the setting under Start Page & Browser -> Internet Explorer -> Advanced -> Computer Identification.

Here is a simple example for a web page that makes redirects based on the extracted computer name.

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<script>
		//Get the SiteKiosk computer name by extracting the computer name from the user agent string.
		var SiteKioskComputerName = navigator.userAgent.substring(navigator.userAgent.lastIndexOf(";")+1);
		document.write("SiteKiosk Computer Name: " + SiteKioskComputerName);
		
		var url = "";
		
		//Assign different URLs based on the computer name.
		if (SiteKioskComputerName.includes("SITEKIOSK_COMPUTER_1")){
			url = "https://www.provisio.com/";
		}
		else if (SiteKioskComputerName.includes("SITEKIOSK_COMPUTER_2")){
			url = "https://www.siteremote.net/";
		}
		else{
			//Place code for no matching computer name here.
		}
		
		//Redirect to content for this specific SiteKiosk terminal.
		if (url !== "")
			document.location.href = url;
	</script>
	<title>Check ComputerName with User Agent</title>
</head>
<body>
<!-- Place code for your HTML body here -->
</body>
</html>

The example is using only native HTML and Javascript, so it will work both in SiteKiosk with a Chrome based browser and in SiteKiosk with an Internet Explorer based browser.

If for whatever reason you can't or don't want to use the customized user agent string option, you can also use the SiteKiosk Object Model. Note that the Object Model versions are different for the Chrome and Internet Explorer browser versions of SiteKiosk. The following example is for the Chrome browser version. The SiteKiosk Object Model for use in the Chrome Browser engine of SiteKiosk is still work in progress and does not offer all the features the classic SiteKiosk Object Model for the IE based engine offers. That is why the documentation is only available on request from our support department.

<html>
<head>
	<meta charset="UTF-8">
	<script>
		//Initialize the SiteKiosk Object Model for Chrome.
		(new Function(_siteKiosk.getSiteKioskObjectModelCode()))();
		
		//Get the SiteKiosk computer name by using the SiteKiosk Object Model.
		var SiteKioskComputerName = siteKiosk.system.environment.getVariable("computerName");;
		document.write("SiteKiosk Computer Name: " + SiteKioskComputerName);
		
		var url = "";
		
		//Assign different URLs based on the computer name.
		if (SiteKioskComputerName.includes("SITEKIOSK_COMPUTER_1")){
			url = "https://www.provisio.com/";
		}
		else if (SiteKioskComputerName.includes("SITEKIOSK_COMPUTER_2")){
			url = "https://www.siteremote.net/";
		}
		else{
			//Place code for no matching computer name here.
		}
		
		//Redirect to content for this specific SiteKiosk terminal.
		if (url !== "")
			document.location.href = url;
	</script>
	<title>Check ComputerName with User Agent</title>
</head>
<body>
<!-- Place code for your HTML body here -->
</body>
</html>

As you can see, the difference between this and the user agent variant is quite small. You need to initialize the Object Model and then use the getVariable method to retrieve the computer name.

If using a browser based on the Internet Explorer, please have a look at the documentation for the classic SiteKiosk Object Model. Specifically the ComputerName property.

Note that for security reasons you need to add pages that are using either version of the SiteKiosk Object Model to the list of URLs with SiteKiosk Object Model Permission in the configuration of SiteKiosk under Access/Security.

For a quick working demonstration of the above you may save the examples as HTML pages, put the in the html subfolder of your SiteKiosk directory and set them as the start page of SiteKiosk.

Using the Classic SiteKiosk Object Model in SiteKiosk Windows Chrome Browser

The SiteKiosk Object Model for use in the Chrome Browser engine of SiteKiosk is still work in progress and does not offer all the features the classic SiteKiosk Object Model for the IE based engine offers. That is why the documentation is only available on request from our support department. To make life a little easier during the transition phase the SiteKiosk Object Model for Chrome offers a way to run the classic SiteKiosk Object Model in a wrapper. Note that this undocumented method comes as-is, it will not enable you to use the full range of the classic SiteKiosk Object Model, e.g. you cannot use code related to controlling the browser window as this specifically refers to the IE based browser and event based code will most likely be problematic.

A simple example looks like this:

var myReturnValue = _siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", "return SiteKiosk.Version.VersionString;");

The callHostFunction method requires two strings. The first string must always be system.windows.skLegacy.executeScript, the second string is the one we use to execute the classic SiteKiosk Object Model code. This can be a single line of code as it is in this example, where we query the version of SiteKiosk installed on the system. The return value is optional, depending on the executed code there may be no return value.

The second string can also have multiple lines, e.g. like in this example that combines the version of SiteKiosk with the build date:

var scriptText = `
	var SKBuildDate = SiteKiosk.Version.BuildDateTime;
	var SKVersionString = SiteKiosk.Version.VersionString;
	return SKVersionString + " " + SKBuildDate;
`;
var myReturnValue = _siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", scriptText);

Finally we want to look at a complete html example that uses methods of the SiteKiosk Multimedia object of the classic object model to manipulate the sound volume of the computer.

<!DOCTYPE html>
<html>
<head>
    <title></title>
	<script>
    //method to initialize the SK Chrome Object Model
    (new Function(_siteKiosk.getSiteKioskObjectModelCode()))();
</script>
</head>
    <body>  
		<input id="id_test0" type="button" value="Volume Up" /><br />
		<input id="id_test1" type="button" value="Volume Down" /><br />
		<input id="id_test2" type="button" value="Volume 50%" /><br />
    </body>
    <script type="text/javascript">
        siteKiosk.ready(function (){
            document.getElementById("id_test0").onclick = function () {
				_siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", "SiteKiosk.Multimedia.IncreaseVolume(0.1);");
            };
			document.getElementById("id_test1").onclick = function () {
				_siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", "SiteKiosk.Multimedia.DecreaseVolume(0.1);");
            };
			document.getElementById("id_test2").onclick = function () {
				_siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", "SiteKiosk.Multimedia.Volume=0.5;");
            };
        }());
    </script>
</html>

You can copy and paste the example to notepad (or another text editor), save it as an html file, e.g. objectmodeltest.html, in the ..\SiteKiosk\html folder. You can then set it as the start page for the Chrome browser of SiteKiosk to see the classic SiteKiosk Object Model at work in the SiteKiosk Chrome browser.

Adding Terms of Use to SiteKiosk Windows and SiteKiosk Android

There are two ways to present terms of use to the user of a SiteKiosk Windows kiosk system, one is also working for SiteKiosk Android. You can either make use of the Fullscreen feature which works in SiteKiosk Windows and SiteKiosk Android or create an overlay by using the SiteKiosk Object Model which works in SiteKiosk Windows only.

1. Fullscreen method (for SiteKiosk Windows and SiteKiosk Android)

The easiest way to present terms of use is to use the Fullscreen feature of SiteKiosk Windows and SiteKiosk Android. Just set your terms of use page as the start page for SiteKiosk.

Under SiteKiosk Windows you then go to Start Page & Browser, click on Fullscreen and set the fullscreen mode for the same URL, you may also select the option to hide the task bar. This works for the Chrome and Internet Explorer browser engines.

Under SiteKiosk Android you go to Application -> Browser -> Fullscreen Zones and also set your start page (which is your terms of use page) to be displayed in fullscreen mode.

Your terms of use page can be stored locally or online. The code for the terms of use page should include on option to accept the terms. If this option is selected the code of the terms of use page simply navigates to a different URL, which is then shown with the normal browser elements.

Sample code for such a page can look like this:

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<script>
	//Terms of use accepted, close the dialog
    function acceptTermsofuse() {
        document.location = "https://www.provisio.com/";
	}
</script>
</head>
<body style="text-align:center;"> 
	Use at your own risk <input type="button" value="OK" onclick="acceptTermsofuse();" />
</body>
</html>

2. Overlay method (for SiteKiosk Windows only)

The other method to show terms of use is to use an overlay over your start page. This can be done by using the SiteKiosk Object Model. First we will create a javascript file, that shows the overlay with the help of the CreateHTMLDialog method. It also shows or hides the overlay on different events (please see the SiteKiosk Object Model documentation for further information). The code for this script file looks like this:

//Initialization of the terms of use dialog
var termsofuseDialog = SiteKiosk.SiteKioskUI.CreateHTMLDialog();
//Path to the terms of use page, this does not have to be local
termsofuseDialog.URL = SiteKiosk.SiteKioskDirectory + "Html/termsofuse.html";
termsofuseDialog.Parent = SiteKiosk.WindowList.MainWindow.Handle;
termsofuseDialog.TopMostWindow = true;
termsofuseDialog.Closable = false;
termsofuseDialog.Title = false;
termsofuseDialog.Border = true;
termsofuseDialog.Scrollbars = false;
termsofuseDialog.Sysmenu = false;
termsofuseDialog.Type = "TERMSOFUSE";
termsofuseDialog.Height = 800;
termsofuseDialog.Width = 1200;
termsofuseDialog.CloseOnInput = false;

//Function that calls the terms of use dialog
function showWindowDelay(){
	termsofuseDialog.ShowModal();
}

//Function that closes the terms of use dialog
function closeDialog(){
	try{
		SiteKiosk.SiteKioskUI.CloseHtmlDialogs('TERMSOFUSE');
	}
	catch(e){}
}

//Show the terms of use dialog when the screensaver ends
SiteKiosk.ScreenSaver.OnScreenSaverEnd = OnScreenSaverEnd;
function OnScreenSaverEnd(){
	SiteKiosk.Scheduler.AddDelayedEvent(1000, showWindowDelay);
}

//Close the terms of use dialog when the screensaver begins
SiteKiosk.ScreenSaver.OnScreenSaverBegin = OnScreenSaverBegin;
function OnScreenSaverBegin(){
	SiteKiosk.Scheduler.AddDelayedEvent(2000, closeDialog);
}

//Show the terms of use dialog when someone uses the logout button
SiteKiosk.OnReset = OnReset;
function OnReset(){
	//Make sure the screensaver is not running
	if (SiteKiosk.ScreenSaver.Active === false){
		SiteKiosk.SiteKioskUI.CloseHtmlDialogs('TERMSOFUSE');
		SiteKiosk.Scheduler.AddDelayedEvent(1000, showWindowDelay);
	}
}

//Show the terms of use dialog when SiteKiosk starts
OnReset();

You can copy and paste the code and save it as a .js file. Put the file into the ..\SiteKiosk\html folder and then add it as an external script to SiteKiosk. For both Internet Explorer and Chrome this is under Start Page & Browser -> Advanced. The following image shows the setting for the Chrome browser engine:

For the actual terms of use page you have two options. The first option does not require any specific code within the terms of use page. Just change the line termsofuseDialog.CloseOnInput = false; to termsofuseDialog.CloseOnInput = true; and any user input, e.g. mouse click, will close the overlay. The second option requires to add SiteKiosk Object Model code to the terms of use page. It makes use of the CloseHtmlDialogs method to close the overlay when the user accepts the terms. Here is a code example of how this can look:

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<script>
	//SiteKiosk Object Model initialization
	window.external.InitScriptInterface();
			
	//Terms of use accepted, close the dialog
    function acceptTermsofuse() {
        SiteKiosk.SiteKioskUI.CloseHtmlDialogs('TERMSOFUSE');
	}
</script>
</head>
<body style="text-align:center;background-color:red;"> 
	Use at your own risk <input type="button" value="OK" onclick="acceptTermsofuse();" />
</body>
</html>

The page can be stored locally under ..\SiteKiosk\html or online. When you store it online or under another local path, you will need to give the URL script permission in the SiteKiosk configuration under Access/Security. Just make sure the line termsofuseDialog.URL = SiteKiosk.SiteKioskDirectory + "Html/termsofuse.html"; from the script above contains the correct path to your terms of use page.

Here is an picture of the above example code at work while using the Chrome browser engine of SiteKiosk Windows:

How to Build an Extended Script Watchdog for External Applications

This time we are going to have a second look at a script watchdog for an external application. The first time we have learned how to monitor an external application and start it again, if it has been closed. Due to some customer requests based on that script watchdog, we are now going to enhance the script by also monitoring if the application has been minimized.

Before you start writing your own script for a SiteKiosk application watchdog please note that you can have SiteKiosk autostart an application and restart it after logout or screensaver activity by just configuring this behaviour in the SiteKiosk configuration. Go to Applications, click Add and select that SiteKiosk starts the application automatically.

The script we are about to create comes in handy, if you want the application to run permanently and you also want it to stay maximized. Whether or not an application can be closed or minimized is beyond what SiteKiosk can directly control, its based on what the original code of the application itself allows. If you have control of that code you should alter it, to prevent the user from doing these things if you do not want that. The script watchdog can take action if you cannot control the code of the application.

The script uses the SiteKiosk Object Model. As it is going to be a an external script and not part of the code of a website it will run with both IE- and Chrome-based versions of SiteKiosk.

We will add the monitoring for minimization of the application to the existing script that already monitors if the application is running. Please refer to the original post to learn more about that part of the code.

First we will add the OnInsert event and a global variable for the object required to handle our application. If OnInsert fires and the title of the application window matches the application to be monitored, we will assign the window object we receive through the event to the global object variable gk_skwin.

...
SiteKiosk.WindowList.OnInsert = OnInsert; //fires if a windows is inserted

var gk_skwin; //global variable for the window object to monitor the application

...
 
function OnInsert(skwin){
	//check if our application has been started
	if(skwin.ItemText === "WindowTitleOfApplicationToWatch"){
        gk_skwin = skwin; //application has been started, assign returned window object to global variable
	}
}
...

The next step is to add a periodic event that will check if our application has been minimized. The check runs every 5000 milliseconds. You can change the time to your liking.

SiteKiosk.Scheduler.AddPeriodicEvent(5000, CheckAppIsMinimized);

The CheckAppIsMinimized function called by the periodic event uses the IsMinimized method to check the application by using the handle from the global object that represents the monitored application. If the monitoried application is minimized, the Maximize method is called to maximize it again.

function CheckAppIsMinimized(){
   //use try/catch in case our application is not started and can therefore not be monitored
   try{
		//check if application is minimized
		if(SiteKiosk.WindowList.IsMinimized(gk_skwin.Handle)){
			//maximize the minimzed application
			SiteKiosk.WindowList.Maximize(gk_skwin.Handle);
		}
   }catch(e){}
}

If we put the code together we will get the follwing script. It uses Notepad to demonstrate its usability. Please note that the script could be a lot more elegant in handling the task at hand but has been kept as straight forward as possible for the purpose of this demonstration

SiteKiosk.WindowList.OnRemove = OnRemove; //fires if a window has been closed
SiteKiosk.WindowList.OnInsert = OnInsert; //fires if a windows is inserted

var gk_skwin; //global variable for the window object to monitor the application

SiteKiosk.Scheduler.AddDelayedEvent(5000, StartMyApp); //starts the desired application the first time after 5000 ms
SiteKiosk.Scheduler.AddPeriodicEvent(5000, CheckAppIsMinimized); //monitors whether application is minimzed every 5000 ms
 
function StartMyApp(){
    SiteKiosk.ExternalApps.Run("c:\\windows\\notepad.exe", true);
}

function OnInsert(skwin){
	//check if our application has been started
	if(skwin.ItemText === "Untitled - Editor"){
        gk_skwin = skwin; //application has been started, assign returned window object to global variable
	}
}
 
function OnRemove(skwin){
    //checks if the application that should run has been closed
    if(skwin.ItemText === "Untitled - Editor"){
        //the application has been closed, restart it again
        SiteKiosk.Scheduler.AddDelayedEvent(500, StartMyApp); //starts the desired application the next time after 500 ms
    }
}

function CheckAppIsMinimized(){
   //use try/catch in case our application is not started and can therefore not be monitored
   try{
		//check if application is minimized
		if(SiteKiosk.WindowList.IsMinimized(gk_skwin.Handle)){
			//maximize the minimzed application
			SiteKiosk.WindowList.Maximize(gk_skwin.Handle);
		}
   }catch(e){}
}

Copy and paste the script into an editor and save it as a javascript file (.js). It is recommended to store it in the ..\SiteKiosk\html folder, to make sure the SiteKiosk user can access it in Autostart mode.

To run the watchdog script with SiteKiosk, open the configuration, go to Start Page & Browser, select your browser engine and click on Advanced. Add the script to be executed on startup of SiteKiosk.

Creating Custom SiteKiosk and Windows Control Elements for the Start Screen

The HTML Widget of the SiteKiosk Start Screen allows you to create custom buttons with your own HTML code. This helps you to create a vast amount of individual features that you can add to your Start Screen.

To demonstrate some of the functionalities you can add, we will create elements that will enable the user to initiate a SiteKiosk restart and logout as well as a Windows logout, shutdown and restart.

Because the design of the SiteKiosk Start Screen is Chrome-based, it uses the new SiteKiosk Object Model for Chrome. This Object Model is still in the making, the most current state of the preliminary documentation can be obtained through our support department. Interested developers can just send us a short email.

To create an HTML Widget, go to the Start Screen Editor in the SiteKiosk configuration (Start Page & Browser -> Select the Start Screen -> Click on Customize -> Start Screen Editor -> Open Editor). Select the blank by default Template 3 and choose to add a new element. Select HTML Widget.

After the new widget has been created, use the edit button to open the properties dialog. On the HTML page you can overwrite the default example code with the custom HTML code.

Let us start with an element that does a SiteKiosk Logout. This is the code needed for it:

<script type="text/javascript">
    function DoSiteKioskLogout() {
        parent.siteKiosk.logout();
    }
</script>
<div style="background-color:FF235A;height:100%;padding:10px;font-family:Arial;cursor:pointer;" onclick="DoSiteKioskLogout();">
	<div style="height:100%;width:100%;font-size:30px;text-align:center;margin-top:42%;">SiteKiosk<br/>Logout</div>
</div>

You can copy and paste it into the HTML editor of the widget. The div tags are used to design the element. Clicking on the main div will call the DoSiteKioskLogout method. This method calls the siteKiosk.logout() method from the SiteKiosk Object Model. Note the leading parent, this is required to access the SiteKiosk Object Model that has already been initialized by the Start Screen, which is the parent of the HTML Widget element.

Next is a SiteKiosk Restart:

<script type="text/javascript">
    function DoSiteKioskRestart() {
        parent.siteKiosk.restart();
    }
</script>
<div style="background-color:1EFF47;height:100%;padding:10px;font-family:Arial;cursor:pointer;" onclick="DoSiteKioskRestart();">
	<div style="height:100%;width:100%;font-size:30px;text-align:center;margin-top:3%;">SiteKiosk<br/>Restart</div>
</div>

You will note that most of the code is the same as before. This is true for all of the five elements we will create in this example. Besides some changes in the CSS to give the element a different look, it calls the DoSiteKioskRestart method which calls siteKiosk.restart() from the SiteKiosk Object Model to execute the restart of the SiteKiosk application.

The last three elements will perform Windows tasks. The code for a Windows Logoff looks like this:

<script type="text/javascript">
    function DoWindowsLogoff() {
        parent.siteKiosk.system.logoff();
    }
</script>
<div style="background-color:FFEC21;height:100%;padding:10px;font-family:Arial;cursor:pointer;" onclick="DoWindowsLogoff();">
	<div style="height:100%;width:100%;font-size:30px;text-align:center;margin-top:3%;">Windows<br/>Logoff</div>
</div>

Clicking this element will logoff the current Windows user and present the Windows login screen. It uses the siteKiosk.system.logoff() mehtod.

A Windows Shutdown will be executed with this code added to an HTML Widget element:

<script type="text/javascript">
    function DoWindowsShutdown() {
        parent.siteKiosk.system.shutdown();
    }
</script>
<div style="background-color:DB28FF;height:100%;padding:10px;font-family:Arial;cursor:pointer;" onclick="DoWindowsShutdown();">
	<div style="height:100%;width:100%;font-size:30px;text-align:center;margin-top:42%;">Windows<br/>Shutdown</div>
</div>

The siteKiosk.system.shutdown() from the SiteKiosk Object Model is used here.

The final example will do a Windows Restart with the help of these lines:

<script type="text/javascript">
    function DoWindowsRestart() {
        parent.siteKiosk.system.restart();
    }
</script>
<div style="background-color:2DA7FF;height:100%;padding:10px;font-family:Arial;cursor:pointer;" onclick="DoWindowsRestart();">
	<div style="height:100%;width:100%;font-size:30px;text-align:center;margin-top:3%;">Windows<br/>Restart</div>
</div>

siteKiosk.system.restart() is the method of the SiteKiosk Object Model that comes into play for this task.

If you add all five examples to the Template 3 and save the configuration, you will get this colorful result when starting SiteKiosk.

Using the External Script Option of SiteKiosk to Automate Processes

SiteKiosk allows you to run an external script, that you can use to automate processes within SiteKiosk. The external script can contain the SiteKiosk Object Model as well as Wsript. That enables you to script a broad spectrum of tasks.

The example we want to build, will demonstrate an automated Gmail login, that will work with the IE and Chrome browser engines of SiteKiosk.

Our example code looks like this:

//Helper variable to prevent multiple SendKeys at once
var currently_sending_keys = false;

//Initialization of the WScript Shell object used for sending keys
var objShell = new ActiveXObject("WScript.Shell");

//OnMessage event fired by the browser used to start looking for the login page
SiteKiosk.Logfile.OnMessage = OnMessage;

//Handling the OnMessage event
function OnMessage(seq, time, utcoff, awtype, awlevel, facility, text){  
   //Check the navigation to identify the login page and whether the script is already sending keys
   if((text === "Navigation: http://www.gmail.com/" || text === "Navigation: http://gmail.com/") && !currently_sending_keys){
	   //Start sending keys so set the helper variable to true
	   currently_sending_keys = true;
	   //Wait a short period of time to give the page time to load and then send the user name
	   SiteKiosk.Scheduler.AddDelayedEvent(1500, SendTheUsername);
   }
}

//Send the user name
function SendTheUsername(eventID){
	objShell.SendKeys("username@gmail.com");
	objShell.SendKeys("{enter}");
	//Wait a short period of time to give the page time to the password part and then send the password
	SiteKiosk.Scheduler.AddDelayedEvent(1500, SendThePassword);
}

//Send the password
function SendThePassword(eventID){
	objShell.SendKeys("password");
	objShell.SendKeys("{enter}");
	//We are done sending keys so set the helper variable to false
	currently_sending_keys = false;
}

Let us have a closer look at some parts of the script.

...
//Handling the OnMessage event
function OnMessage(seq, time, utcoff, awtype, awlevel, facility, text){  
   //Check the navigation to identify the login page and whether the script is already sending keys
   if((text === "Navigation: http://www.gmail.com/" || text === "Navigation: http://gmail.com/") && !currently_sending_keys){
...

The script uses the OnMessage event of the SiteKiosk Object Model to track navigations. If it finds matching navigations to either www.gmail.com or gmail.com and it is currently not sending keys it triggers the automated login.

...
SiteKiosk.Scheduler.AddDelayedEvent(1500, SendTheUsername);
...

Utilizing the AddDelayedEvent method, the script gives the page some time to load. You may need to adjust the time depending on your Internet connection. The function to send the first set of keys for the user name of the Gmail login process is called next.

...
objShell.SendKeys("username@gmail.com");
...

The SendKeys method of the WScript Shell object is used to send key strokes to the browser. First the user name, then the enter key to trigger the password request. Finally the script starts a similar process for the password input mask.

Save the above example code as a javascript file (e.g. automated_gmail_login.js), preferably in the html subfolder of your SiteKiosk installation. Now in the SiteKiosk configuration you have to add the file as an external script. Go to Start Page & Browser and click on the Advanced button. Now you can tick the option that SiteKiosk should execute the script on startup.

Save the configuration and for testing purposes use the Run Once Mode of SiteKiosk. Type in gmail.com or www.gmail.com in the address field of the SiteKiosk browser. The script will attempt to make an automated login with the provided user name and password. Note that the above example script may stop working if the Gmail page layout changes.

Debugging Webpages in the SiteKiosk Windows Chrome Browser

When you are using the SiteKiosk Windows Chrome Browser you can activate the Chrome DevTools to debug web pages in SiteKiosk.

To activate this option, you need to create an empty text file with the file name debug.txt. This file must be placed in the folder ..\SiteKiosk\Chromium\.

When you start SiteKiosk with the Chrome Browser engine after that change, you can click on the browser pane of SiteKiosk and hit the F11 button to open up the Chrome DevTools window.

Remember to delete or rename the debug.txt file after you are done with debugging.

How to Use a Proxy Auto-Config File with SiteKiosk Windows

This time, we will have a look at the different ways to use a proxy auto-config (PAC) file with SiteKiosk.

There are two different methods, depending on the SiteKiosk browser engine you plan to use. No matter which engine you are using, you need to disable the Use proxy server setting of SiteKiosk, otherwise SiteKiosk will use the proxy settings defined in its configuration file instead of those from the PAC file.

When you are using the Internet Explorer engine, SiteKiosk uses the Microsoft IE settings, including a PAC file assigned there. Note that the IE settings are user dependent, so make sure to make these settings within the Internet Explorer of the user you want to run SiteKiosk with.

When you are using the Chrome Browser engine, you need to add your PAC file manually to the configuration of SiteKiosk. Open your SiteKiosk configuration with an editor like notepad. Search for this line:

"showTaskBar": true,

Add these lines right before the showTaskBar line:

"browserEngine": {
       "commandLineArguments": {
           "set": ["proxy-pac-url=urlzuihrerpacdatei"],
           "remove": []
       }
   },

It should look like this:

…
"system": {
    "password": {
      "enabled": false
    },
    "browserEngine": {
       "commandLineArguments": {
           "set": ["proxy-pac-url=UrlToYourPacFile"],
           "remove": []
       }
	},
    "showTaskBar": true,
    "userAgent": {
…

Of course you need to change UrlToYourPacFile to the actual path to your PAC file, e.g. something like file://C:/mylocalpacfile/proxy.pac or http://192.168.99.1:8088/proxy.pac. The configuration part would then look like this:

…
"system": {
    "password": {
      "enabled": false
    },
    "browserEngine": {
       "commandLineArguments": {
           "set": ["proxy-pac-url=file://C:/mylocalpacfile/proxy.pac"],
           "remove": []
       }
    },
    "showTaskBar": true,
    "userAgent": {
…

Please note that the content filter of SiteKiosk does not support using PAC files. Please use the proxy configuration settings of SiteKiosk instead.

Specifically Deny Downloads of Certain File Types

SiteKiosk enables you to only allow the download of certain file types only. You can do this in the configuration editor under Files & Downloads. In rare cases you might need to do the opposite, because you only want to block a handful of file types instead of allowing only a handful of file types.

There are two different ways to achieve this. In both cases you would generally allow downloads in the configuration of SiteKiosk under Files & Downloads. Then, one option is to use the Surfing Area settings. Just create deny entries for each file type you want to block. Use * for the protocol and *.filetypetoblock (e.g. *.zip) for the URL. This only works if the download is a direct link to the file.

The second option applies to the IE engine of SiteKiosk only. You can edit the file ..\SiteKiosk\xml\downloadmanager.xml with a text editor (e.g. Notepad). In the file there is a file extension list that already includes a number of default entries. Just add additional entries for the file types you want to block and set both the values for download and for open to 0. Just like this:

<extension name='zip' download='0' open='0'/>

This tells SiteKiosk to neither download nor open the file. Place the entries at the end of the existing list. You may also edit an existing entry. Make sure to not use the same extension twice, SiteKiosk will only use the first match in the list.

<extension-list>
	<extension name='exe' download='2' open='0'/>
	<extension name='dll' download='2' open='0'/>
	<extension name='htm' download='1' open='2'/>
	<extension name='html' download='1' open='2'/>
	<extension name='pdf' download='2' open='1'/>
	<extension name='jpg' download='2' open='2'/>
	<extension name='gif' download='2' open='2'/>
	<extension name='png' download='2' open='2'/>
	<extension name='txt' download='2' open='2'/>
	<extension name='zip' download='0' open='0'/>
</extension-list>

This will block matching download attempts in SiteKiosk.