onscryn

Design a Windows app
so UI automation just works.

Whether a workflow against your app takes an afternoon or a month depends on decisions made when the app was built. They are cheap to make and expensive to retrofit. These are the rules the reference app followed, with the reasons.

By the Onscryn team · Published · 7 min read

Why this matters

Automation sees your app through UI Automation, the same tree that screen readers use. It lists the controls on screen with a role, a name and some text. The better your controls describe themselves, the less a workflow has to guess.

Name every control

A workflow that says click btnSubmitOrder survives a redesign. One that says click the third button does not. In WinForms the Name property becomes the id, and in WPF it is the AutomationId. Choose names once, keep them, and treat a rename as a breaking change.

One screen at a time

Hidden controls drop out of the tree. If you swap screens by hiding and showing panels, the ids of the other screens never clash with the visible ones. A single window that stacks every control on top of the others is the hardest case.

Choices that automate well

The pattern is to remove steps that only a human eye can do.

  • Radio buttons and list rows over combo boxes, because a drop-down opens in a separate window that the tree does not walk.
  • A list that selects its only row on its own, so a workflow can search and then press the action button.
  • Visible, named buttons for actions that would otherwise live in a menu.

Say what happened

Write every outcome to a status line with its own name: order created, only three in stock, invoice already paid. Workflows can wait for it, branch on its text and report it. An app that signals failure only by a sound or a color forces automation to guess.

Make data resettable

Give the app a way to return to known data, as a button or an action. Tests and demos then start from the same place every time, and a workflow can end by tidying up.

What to avoid

Owner-drawn controls that paint their own pixels expose nothing to UI Automation unless you implement it. Modal prompts that need a human stop a headless run. Changing control names between releases breaks every saved workflow.

Related features

Questions.

No. Apps captured without the SDK also get a UI tree. The SDK publishes it from inside the app, and adds named actions, which a UI tree alone cannot give you.

Try it on
your own app.