onscryn

Turn a Windows app into an API
with named actions.

A lot of business software has no API and never will. The usual workaround is to script its screens, which breaks the first time a button moves. If you can change the app, there is a better way: expose a few functions from inside it and let automation call those instead.

By the Onscryn team · Published · 7 min read

Why scripting screens is fragile

Screen automation has to find a control, wait for the right screen, and cope with anything that changes the layout. It is also blind to data: it can click a row, but it cannot ask for the order.

A function does not care how the screen looks. Ask for order SO-10046 and you get the order, whether the app is on the dashboard or the sign-in page.

What a named action is

You register a handler under a name with a one-line description. When automation calls the name, the SDK runs your handler with the parameters as JSON. Your handler does the work and answers with a success flag and a JSON result. The SDK keeps the catalog of names and replies to unknown names for you.

A worked example

Take an order system. Registering getOrder, listOrders and approveOrder is a handful of lines each, because the logic already exists in your app. A workflow can then read the day's orders as data, loop over the ones awaiting approval, and call approveOrder for each, without opening a single screen.

The reference app behind the live demo exposes actions such as getDashboard, listOrders with an optional status, getOrder, listInvoices and resetDemo in exactly this way.

The picture and the people

  1. 01

    Your app, with the SDK

    Draws its own window and hands the picture over.

  2. 02

    Onscryn on your host

    Streams it and applies your clipboard, file and watermark rules.

  3. 03

    A browser tab

    Shows the app. Mouse, keys, uploads and drops go back.

Automation

  1. 01

    A workflow, webhook or schedule

    Runs on demand or on a timer.

  2. 02

    Onscryn

    Starts a session, even with no browser attached.

  3. 03

    A named action in your app

    A function you registered. Returns JSON.

The same app serves both: people through the browser, and automation through the functions it chooses to expose.

Calling them

In the workflow builder you add a run-action step and pick one of your actions. Parameters can use variables from earlier steps and the result feeds later steps and conditions. The same workflow runs on a schedule, from a webhook URL or on demand, and every run is recorded.

Rules that keep actions reliable

A few habits matter more than any clever design.

  • Reply exactly once to every call, including when something fails.
  • Do not open dialogs or wait on the UI thread from a handler. Handlers run on a thread of their own.
  • Return JSON objects, not text meant for people.
  • Keep reads free of side effects and make writes safe to repeat.
  • Add a reset action, so tests and demos begin from known data.

Where actions stop

An action can only do what you wrote it to do. For a screen that has no action yet, a workflow can still click and type, using names from the UI tree. A good migration is gradual: wrap the three functions people call most as actions and leave the rest on screens until they earn one.

Related features

Questions.

No. A workflow can start a session with no viewer attached, call an action, collect the result and end the session.

Try it on
your own app.