0
votes

Error image

InputInjector inputInjector = InputInjector.TryCreate();
var shift = new InjectedInputKeyboardInfo();
shift.VirtualKey = (ushort)(VirtualKey.Shift);
shift.KeyOptions = InjectedInputKeyOptions.None;

var tab = new InjectedInputKeyboardInfo();
tab.VirtualKey = (ushort)(VirtualKey.Tab);
tab.KeyOptions = InjectedInputKeyOptions.None;
inputInjector.InjectKeyboardInput(new[] { shift, tab });
shift.KeyOptions = InjectedInputKeyOptions.KeyUp;
tab.KeyOptions = InjectedInputKeyOptions.KeyUp;

Please have look at this image and tell me what should i do to fix this problem

1
Please don't post images of code, instead edit your question to include your code (an minimal reproducible example) as well as any input and desired output along any error messages you may or may not be gettingMindSwipe
Code added, but please look at the image too.Hana Munamana
Please always include the error message as text and not images too.DavidG

1 Answers

0
votes

If you look at the docs for the InputInjector.TryCreate() method, it says:

Note: The APIs in this namespace require the inputInjectionBrokered restricted capability.

You need to update your Package.appxmanifest to add the capability, for example:

<?xml version="1.0" encoding="utf-8"?>
<Package
    ...
    xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    IgnorableNamespaces="... rescap">
...
<Capabilities>
    <rescap:Capability Name="inputInjectionBrokered"/>
</Capabilities>
</Package>