SendKeys for WPF?
Perhaps this will be useful to somebody… (mail thread, read bottom-to-top)
You should consider intercepting the input at a common parent, and then invoking methods/commands on the separate controls. For example, you can change selection of the list boxes programmatically.
I’ll look at KeyDown. Is it still spoofing if the app is sending keys to itself? In my scenario if the user presses the Up/Down keys I want to navigate through a vertical listbox or if they are using the Right/Left keys I want to navigate through a horizontal listbox. Since you can’t have focus on both listboxes at once I thought by capturing the Page’s KeyUp I might be able to broker control for both listboxes.
Not generally. You are describing input spoofing, and we work hard to prevent it.
1) PInvoke to SendInput – this is the official way to simulate input. It pushes the input through all of the expected code paths, and is indistinguishable from real input.
2) Raise the KeyDown event on the element you care about – there are bits of state that you cannot pass around with this method.
Is there a way to send keys to a WPF control like a listbox? So let’s say I’m handling the KeyUp event for a Page or Window, can I pass that keystroke over to a specific control?