I have a WPF desktop application written with NET Core 3.1 and it catches keystrokes with KeyDown command. All characters are caught with the keyboard. When I use a Streamdeck and its System Text feature, which sends keys like a keyboard my WPF app doesn't catch it.
Tested on Notepad and the text sent from the Streamdeck works as it should, e.g. X 1 Enter.
When I debug the only thing that gets sent is Enter key.
private void MyApp_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.X)
{
//do something
}
}
Everything works fine with a normal keyboard. Barcode Scanner works too. It's the Streamdeck that won't catch the text it sends.
Is there anything I need to set in my project to catch it?
I myself am interested in Elgato Stream Deck a little and so tried Stream Deck Mobile app. I found when the app sends a text, a pair of
WM_KEYDOWNandWM_KEYUPwindows messages withVK_PACKETvirtual-key code are sent for each letter. It suggests the app utilizes SendInput function to "send Unicode characters as if they were keystrokes".Then, luckily I found
UIElement.PreviewTextInputevent can capture each letter. So, assuming the text ends with Enter key, we can retrieve the text sent by the app by aggregating the letters.