User Tools

Site Tools


webremote:scripting

Scripting Web Remote:

As of XTension 9.5.3 I’ve added some scripting commands to control what is displayed and to send alerts to the sessions. This may be most useful with Kiosk Mode but can be used anywhere. Note that these functions only apply to the full sized web remote and are not implemented in the mobile browser version.

Commands can be sent to all sessions, or just to specific named sessions so that displays on different screens can be controlled.

These are not traditional AppleScript verbs, but handlers that must be targeted to the specific interface that you want to control. Do this via the standard tell block syntax like:

tell xInterface “web remote” to doSomething()

Note that the parans around the parameters or empty in the case of commands without parameters are not optional and must be included,

For the examples below I’ll be using “Web Remote” as the interface name, but you would replace that with the actual name you have given the instance of the Web Remote plugin to which you want to send the command. The command names are not case sensitive but the other verbs and session names are.

If there is more than one machine logged in with the same session name then any session targeted commands will be sent to all the sessions with that name.


Name Your Session:

For easier use in Kiosk mode I’ve added a “keep me logged in“ option and session name field to the login screen. If you check this then an access token will be stored as a cookie in the browser which will keep you logged in for up to a year or until you log out. The name you give the session is important as that will be used when scripting to target your commands to the right browser window.

The second way to stay logged in and save a session name is to use the Save This Browser Session menu item in the Admin menu. This will also give you an opportunity to set the access token and session name for scripting.

The session name is also displayed in a floating alert for a few seconds when the machine logs back in,


Show Alert In All Sessions:

There are 2 sizes of alert windows that can be popped up. Neither will handle long alert lines well so you should keep the text short enough to fit or it may be truncated.

Show Alert In All Sessions: Sends a small popup to every machine currently connected to the web remote.

ShowAlertInAllSessions( “Required: Alert Text”, Optional: how many seconds to display the popup for, “Optional: An RGB color string for the background of the alert.”)

tell xInterface  “Web Remote” to showAlertInAllSessions( “Someone At The Front Door”, 5, “FF4444")

Would display the alert for 5 seconds on a red background. The default is the blue background that is used when the system sends you a message.

For a larger text version of the alert easier to read on kiosk screens or from further away use the command: showLargeAlertInAllSessions


Show Alert In Session:

Show Alert In Session: Sends a small popup to only the named session you pass. ShowAlertInSession( “Required: Session Name”, “Required: Alert Text”, Optional: seconds to display, “Optional: RGB Color string for alert background”)

tell xInterface “Web Remote” to showAlertInSession( “Kitchen Kiosk”, “Someone At The Front Door”, 5, “FF4444”)

would display the same message but only in the session saved with the name “Kitchen Kiosk”. For a larger alert message use the command: showLargeAlertInSession:


Send Session To:

This command will let you change the page or kiosk view that is displayed in a session. This is more useful for Kiosk views as you could switch to one of a video stream of the front door camera when a human was detected at the front door and then after a time or when no human is there switch back to the normal weather and status view or something similar.

The capabilities of the send session to command are basically the same as what you can do with the Kiosk Hashtag Display Control,

Send To Main Page:

The simplest command is just passing the name of the session and then the string “main” which will send the session to the Main page of the web remote.

tell xInterface “Web Remote” to sendSessionTo( “Kitchen Kiosk”, “main”)

Send To A Custom Page:

To send the session to a specific custom page that would normally need to be selected from the menu bar (you can hide the menu bar if you’re in kiosk mode and the admin menu if you do not wish the session to be able to make changes to the interface) you must send 3 parameters, the session name, the type of page, in this case “custom” and then the name of the page.

tell xInterface “Web Remote” to sendSessionTo( “Kitchen Kiosk”, “custom”, “Front Video”)

it is up to you in your scripts to create a scheduled event or other timed method for returning the display to the Main page or whatever you are using as the main display for the kiosk.

Send To a Unit List Page:

To send the session to a unit list pass the name of the session, the key word “list” and the name of the XTension Unit List.

tell xInterface “Web Remote” to sendSessionTo( “Kitchen Kiosk”, “list”, “Kitchen Lights”)

Send To A View:

Perhaps the most useful to those building a kiosk or other touch screen display is the ability to go to a View. If you create a View in XTension you can display just that view, centered in the browser window with no menu bar or other controls. This was specifically designed for a kiosk or other similar display. You can create many Views in XTension and switch between them either automatically in response to events, other remote inputs, or via script buttons on the views themselves to create your own touch screen navigation. To send a session to a View you must pass the session name, the keyword “view” and the view name.

tell xInterface “Web Remote” to sendSessionTo( “Kitchen Kiosk”, “view”, “Time And Weather”)

Send To A URL:

Lastly you can send the browser window to a URL. Unless this url is another Web Interface instance you will no longer be able to control the browser or bring it back to one of the regular pages or views. To do this pass the name of the session, the keyword “url” and then the url you wish to send the browser to.

tell xInterface “Web Remote” to sendSessionTo( “Kitchen Kiosk”, “url”, “https://cnn.com”)

Show Message Box:

Like the alert commands above you can also popup a “message box” style alert. This is not formatted and displays only small plain text. It will not disappear on it’s own and requires that a person click the “OK” button at the bottom. This is perhaps best used for debugging, or other development tasks. It comes in the same 2 forms for sending to all sessions, and sending to a specific session.

tell xInterface “Web Remote” to showMessageBoxInAllSessions( “You must click OK to make this go away”)

tell xInterface “Web Remote” to showMessageBoxInSession( “Kitchen Kiosk”, “You must click OK to make this go away”)

Log Currently Active Sessions:

Lastly is a command that will write to the log a list of currently active sessions. This does not return the data to the script itself so cannot be used to programmatically check to see if a machine is logged in or not but is a useful debugging tool when you didn’t remember what you called the session exactly on the machine downstairs and you want to see what it was for use in one of the above commands.

tell xInterface “Web Remote” to logSessions()
webremote/scripting.txt · Last modified: 2023/05/09 14:46 by James Sentman