How to simulate user interaction in WinUI3 desktop application

Harshithraj1871 1,581 Reputation points
2025-02-20T07:21:11.4566667+00:00

Hi,

I'm working on WinUI3 desktop application in CPP. I want to test my application for user interaction like keyboard input, mouse input, dragging widgets/ Window, sending OS events, etc. I tried simulating with SendInput API, it did work well, but is there any other options to simulate user interaction events with out any 3rd part application?

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
827 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 10,626 Reputation points Microsoft Vendor
    2025-02-21T02:21:49.7866667+00:00

    Hi,

    Welcome to Microsoft Q&A!

    You could try to use Windows.UI.Input.Preview.Injection to simulate and automate user input from devices such as keyboard, mouse, touch, pen, and gamepad in your Windows applications.

    Please note that input injection APIs require restricted capabilities. You will need to add inputInjectionBrokered as estricted capability in your manifest first.

    <rescap:Capability Name="inputInjectionBrokered" />
    

    For more details you could refer to the Doc: Simulate user input through input injection

    Thank you

    Jeanine

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.