I'm using InputInjector to simulate a mouse click on a UI element in my custom UWP control (which is included into a WPF application using XamlHost). I implemented based on this article. It works fine on my PC, but on another PC can't create the Input Injector instance. When the InputInjector.TryCreate(); is called, it throws the following exception:
System.Runtime.InteropServices.COMException (0x80010117): Call context cannot be accessed after call completed. (0x80010117)
at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
at Windows.UI.Input.Preview.Injection.InputInjector.TryCreate()
at >MyMethod()<
What this exactly mean? I tried to run this function on UI and background threads as well, but both fails. What could be the issue?
Update:
The other PC's OS version is 1909 (build 18363.1316), my PC's version is newer: 2004. As I see the InputInjector was introduced in 10.0.14393.0