SendKeys for WPF?
Perhaps this will be useful to somebody… (mail thread, read bottom-to-top)
From: Answerer
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.
From: Asker
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.
From: Answerer
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.
From: Asker
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?
Never mind — found a cool solution at codeplex for this
http://inputsimulator.codeplex.com/
I don’t know whether this is active site (last update 2007)
But here’s my problem.
I want to make a client software that can control media applications. How can I sent media keys to any running media apps ? I’d prefer a WPF way as my client end will have a simple UI.
If not, please let me know of a P/Invoke based way.