How to Handle App Focus When Launching Another App During Secure Event Input

Hi everyone,

I'm encountering a behaviour related to Secure Event Input on macOS and wanted to understand if it's expected or if there's a recommended approach to handle it.

Scenario:

App A enables secure input using EnableSecureEventInput().

While secure input is active, App A launches App B using NSWorkspace or similar.

App B launches successfully, but it does not receive foreground focus — it starts in the background.

The system retains focus on App A, seemingly to preserve the secure input session.

Observed Behavior:

From what I understand, macOS prevents app switching during Secure Event Input to avoid accidental or malicious focus stealing (e.g., to prevent UI spoofing during password entry). So:

Input focus remains locked to App A.

App B runs but cannot become frontmost unless the secure input session ends or App B is brought to the frontmost by manual intervention or by running a terminal script.

This is consistent with system security behaviour, but it presents a challenge when App A needs to launch and hand off control to another app.

Questions:

Is this behaviour officially documented anywhere?

Is there a recommended pattern for safely transferring focus to another app while Secure Event Input is active?

Would calling DisableSecureEventInput() just before launching App B be the appropriate (and safe) solution? Or is there a better way to defer the transition?

Thanks in advance for any clarification or advice.

How to Handle App Focus When Launching Another App During Secure Event Input
 
 
Q