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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | var currently_sending_keys = false ;
var objShell = new ActiveXObject( "WScript.Shell" );
SiteKiosk.Logfile.OnMessage = OnMessage;
function OnMessage(seq, time, utcoff, awtype, awlevel, facility, text){
currently_sending_keys = true ;
SiteKiosk.Scheduler.AddDelayedEvent(1500, SendTheUsername);
}
}
function SendTheUsername(eventID){
objShell.SendKeys( "username@gmail.com" );
objShell.SendKeys( "{enter}" );
SiteKiosk.Scheduler.AddDelayedEvent(1500, SendThePassword);
}
function SendThePassword(eventID){
objShell.SendKeys( "password" );
objShell.SendKeys( "{enter}" );
currently_sending_keys = false ;
}
|
Let us have a closer look at some parts of the script.
1 2 3 4 5 6 | ...
function OnMessage(seq, time, utcoff, awtype, awlevel, facility, text){
...
|
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.
1 2 3 | ...
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.
1 2 3 | ...
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.
Be the first to rate this post
- Currently .0/5 Stars.
- 1
- 2
- 3
- 4
- 5