Voice Input is an open-source C# app that turns speech into text and types it wherever the cursor sits. The hard part is not recognition but handing a string to a foreign window without stealing focus, losing the clipboard or racing a late Esc.
Key points
- The target HWND and process ID are captured on the hotkey press, not when the model returns.
- The recording overlay uses WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW and WS_EX_TRANSPARENT so it never takes focus.
- Classic Edit and RichEdit fields get one EM_REPLACESEL message via SendMessageTimeout with SMTO_ABORTIFHUNG.
- Everything else goes through the clipboard plus Ctrl+V, with a VoiceInput.ClipboardGuard marker deciding whether to restore.
- Clipboard access retries up to eight times with 20 ms pauses because WPF throws ExternalException when another process holds it.
- A generation counter stops a queued Esc from a previous dictation cancelling the next one.
Real-world use
- Dictating into a chat app, email client, browser or code editor at the current cursor position
- Typing directly into WinForms text fields that expose a classic Edit class name
- Pasting into Electron, Office and browser inputs that have no standard edit control
- Running an end-to-end dictation test against a real WinForms window on the desktop
This summary was generated by the agent from the original post on Habr C# (ru). The full text and all rights belong to its author and publisher. Go to original