How to launch applications from the download manager

The following developer blog entry describes how to open certain file types in predefined applications over the download manager. This developer blog entry works only with SiteKiosk Online for Windows. 

We start by creating a project using the browser template.

In the Webpage element settings, under Browser UI, select the Downloads checkbox and save the setting.

In the project, press the Settings button and in the Downloads section, select the Allow Downloads check box.

Go to Settings - Client - Advanced and press the Add settings button.

Enter the path downloads.downloadFileActions which offers you following default value:

 

[
    {
        "extension": "pdf",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {
        "extension": "txt",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {
        "extension": "png",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {
        "extension": "gif",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {
        "extension": "jpg",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {
        "extension": "jpeg",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {
        "extension": "exe",
        "customApplicationPath": "",
        "actionType": "downloadOnly",
        "autoExecute": false
    },
    {
        "extension": "zip",
        "customApplicationPath": "",
        "actionType": "downloadOnly",
        "autoExecute": false
    },
    {
        "extension": "7z",
        "customApplicationPath": "",
        "actionType": "downloadOnly",
        "autoExecute": false
    }
]

Copy the complete value section and enter the content to texteditor application.

Now you have two options to configure the file action: OpenWithCustomApplication to open Files with a defined extension over a custom application or OpenWithWindowsStandardApplication, to launch the standard application of the system. In the Following example we change the entry for the extension pdf from: 

 

{
        "extension": "pdf",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },

 to

{
        "extension": "pdf",
        "customApplicationPath": "C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe",
        "actionType": "OpenWithCustomApplication",
        "autoExecute": false
    },

   

So with pressing the Open Button on a downloaded PDF file in the download manager the PDF will be opened with the Acrobat Reader.

In the second example, we add the following entry at the end of the array separated by a comma to the previous entry:

 

{

        "extension": "docx",
        "customApplicationPath": "",
        "actionType": "OpenWithWindowsStandardApplication",
        "autoExecute": false

    }

So with pressing the Open Button on a downloaded docx file in the download manager the file will be opened with the standard application Word. With these modification the value looks like this.

Example:

Path: downloads.downloadFileActions

Value:

 

[
    {

        "extension": "pdf",
        "customApplicationPath": "C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe",
        "actionType": "OpenWithCustomApplication",
        "autoExecute": false
    },
    {
        "extension": "txt",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {

        "extension": "png",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {

        "extension": "gif",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {
        "extension": "jpg",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {

        "extension": "jpeg",
        "customApplicationPath": "",
        "actionType": "openInSiteKiosk",
        "autoExecute": true
    },
    {
        "extension": "exe",
        "customApplicationPath": "",
        "actionType": "downloadOnly",
        "autoExecute": false
    },
    {
        "extension": "zip",
        "customApplicationPath": "",
        "actionType": "downloadOnly",
        "autoExecute": false
    },
    {
        "extension": "7z",
        "customApplicationPath": "",
        "actionType": "downloadOnly",
        "autoExecute": false
    },
    {
        "extension": "docx",
        "customApplicationPath": "",
        "actionType": "OpenWithWindowsStandardApplication",
        "autoExecute": false
    }
]

Copy and paste the whole value to the advance setting dialogue and save the advanced setting.

Publish the project to the client on which Adobe Acrobat Reader is installed and Word is set the default app to open docx.

To test the file actions download a Word and a PDF file and open them over the download manager.

How to configure buttons to start external applications over the start menu and taskbar

This devblog entry describes how to generate buttons for launching external applications in the SiteKiosk Online Client for Windows via the Start menu or the taskbar. This is especially useful for full-screen browser projects where you want to launch external applications that are controlled by SiteKiosk.

The following entry works with SiteKiosk Online Client for Windows version 1.1.2539.6604 or higher (https://sitekiosk.online/). Note that it can only be used for windows clients. In this example Notepad is starting over customized buttons in the start menu and taskbar.

We start with generating a project with the template browser. 

Go to Settings - Client - Advanced and press the Add settings button

Enter the Path applications and following value:

[

    {

        "name": "notepad",

        "startParameters": {

            "kind": "executable",

            "executable": {

                "filePath": "C:\\WINDOWS\\system32\\notepad.exe",

                "arguments": null,

                "startAsChildProcess": false

            }

        }

    }

]

 

Save the setting.

To generate a taskbar button, press the Add settings button.

Enter the path ui.taskbar.taskbarEntries and add following value:

[

    {

        "name": "logoutSiteKiosk"

    },

    {

        "name": "startApplication",

        "startApplication": {

            "name": "notepad"

        }

    }

]

 

Save the setting.

To activate the start menu, press the Add settings button.

Enter the path ui.taskbar.showStartMenu and check the checkbox.

 

To generate a start menu entry, press the Add settings button.

Enter the path ui.taskbar.startMenuEntries and following value:

[

    {

        "name": "logoutSiteKiosk"

    },

    {

        "name": "startApplication",

        "startApplication": {

            "name": "notepad"

        }

    }

]

 

Save the setting and close the Clients setting dialog with pressing the button save.

Publish your project to test the settings.

How to Trigger a Customizable Navigation Command in SiteKiosk Windows Chrome Browser from Another Application

We will create a little C# example to show how to trigger a navigation in the Chrome Browser of SiteKiosk Windows from an external application.

It makes use of the SendCustomCommand method from the ISiteKiosk9 object, that is part of the SiteKioskRuntime type library (..\SiteKiosk\Typelib\SiteKioskRuntime.tlb). Add the library to your C# project and access the ISiteKiosk9 object similar to what you find in this description (https://www.provisio.com/helpconsole/SiteKiosk%20Object%20Model%20Help/en-US/default.htm?codesamples_accessobject.htm).

The main part of the code for a small application with a button to call https://www.provisio.com/ looks like this:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using SiteKioskRuntimeLib;

namespace NavigateInSKWchrome
{
    public partial class Form1 : Form
    {
        [DllImport("ole32.dll", CallingConvention = CallingConvention.StdCall)]
        public static extern int CoGetClassObject(ref Guid rclsid, uint dwClsContext, IntPtr pServerInfo, ref Guid riid, out IntPtr ppv);

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // initialize GUID's for classes and interfaces
            Guid lr_FactoryGuid = typeof(ISiteKioskFactory).GUID;
            Guid lr_FactoryClass = Guid.Parse("1CA0D073-4ABB-4D06-B318-BFFDE38E4903");
            Guid lr_SiteKioskGuid = typeof(ISiteKiosk9).GUID;

            ISiteKiosk9 mk_pSiteKiosk;

            // try to get the ISiteKioskFactory interface of the instance
            // of SiteKioskFactoryClass
            IntPtr lk_FactoryPtr = new IntPtr();
            CoGetClassObject(ref lr_FactoryClass, 4, new IntPtr(), ref lr_FactoryGuid, out lk_FactoryPtr);
            
            // convert the received IntPtr to the requested ISiteKioskFactory
            // interface
            ISiteKioskFactory lk_Factory = (ISiteKioskFactory)Marshal.GetObjectForIUnknown(lk_FactoryPtr);

            // call CreateSiteKiosk to get the ISiteKiosk interface of the
            // current instance of SiteKiosk
            IntPtr lk_SiteKioskPtr = new IntPtr();
            lk_Factory.CreateSiteKiosk(ref lr_SiteKioskGuid, out lk_SiteKioskPtr);

            // convert the received IntPtr to the requested
            // ISiteKioskFactory interface
            mk_pSiteKiosk = (ISiteKiosk9)Marshal.GetObjectForIUnknown(lk_SiteKioskPtr);

            mk_pSiteKiosk.SendCustomCommand("openBrowser", "https://www.provisio.com/");
        }
    }
}

When building the project, make sure to build it as an x86 project, so that it can communicate with SiteKiosk. Also make sure that you run the application within the same user context as SiteKiosk, otherwise the application will not be able to access SiteKiosk.

SendCustomCommand can also be used from an external script by simply calling this line in an external Javascript file:

SiteKiosk.SendCustomCommand("openBrowser", "https://www.provisio.com/");

Note that the SendCustomCommand method is handled in the file ..\SiteKioskNG\assets\rootApp\modules\browser.js. By default the onCustomCommand method, that is fired when a custom command is received, only includes the openBrowser command. It uses the navigateinMainBrowser method to open the requested page in a new tab, when the first parameter is false, or in the acitve tab, when the parameter is true. Feel free to add your own code to the browser.js file to enable your own custom commands to be used with the Chrome Browser of SiteKiosk Windows.