dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
6.93k stars 1.15k forks source link

SendInput API does not work on WPF NetCore controls #1993

Closed IGMikeS closed 4 years ago

IGMikeS commented 4 years ago

.NET Core Version: Version: 3.0.100-preview6-012264 Have you experienced this same bug with .NET Framework?: No Windows 10

I have some code that calls the SendInput Windows API in order to simulate keystrokes to a WPF control. This code works fine in the DotNetFramework and triggers all of the appropriate events such as PreviewKeyDown, KeyDown, PreviewTextInput, TextInput, PreviewKeyUp, and KeyUp.

The same code does not work in NetCore. No events are fired.

I have attached sample solution here which contains two projects. One is using the DotNetFramework (DNFApp) and the other is using NetCore (NCApp). Both projects share the same code files.

If you run the DNFApp and click the button, the Output window shows that all of the appropriate events are fired on the Button control.

Run the NCApp and click the button, the Output window shows that the button click fires, and nothing else. If you press a keym such as ("F") on the keyboard, all of the events fire.

SendInputTest.zip

IGMikeS commented 4 years ago

Looks like this is not a NetCore issue. It's just that the API is not working in 64-bit. I must have the definition wrong or something. Closing the issue.