question

richardbraun avatar image
0 Votes"
richardbraun asked richardbraun edited

InputInjection not waking display in assigned access mode

Hi,

I have an UWP app that needs to manage the display. I am already able to switch the dispaly off using P/Invoke of the "user32.dll". However, sadly, one cannot switch the monitor on again using this method. My display briefly turns on and off without ever displaying something. The agreed workaround in the community seems to be to simulate some kind of input to the system to make it switch on the display itself. This works fine on my regular Windows administrator account using this code:

                 InputInjector _inputInjector = InputInjector.TryCreate();
                 _inputInjector.InitializeTouchInjection(
                     InjectedInputVisualizationMode.Default);
    
                 InjectedInputMouseInfo info = new InjectedInputMouseInfo();
                 info.MouseOptions = InjectedInputMouseOptions.Wheel;
                 unchecked
                 {
                     info.MouseData = (uint)-500; //scroll down
                 }
    
                 _inputInjector.InjectMouseInput(new List<InjectedInputMouseInfo> {info});

When I try to run the app in assigned access mode though, the display doesn't get switched on anymore. I've already tried whether it is possible to use input injection in assigned access mode in general, which works absolutely fine. However, I think that the injected input (with the display switched off) is handled differently by Windows when in assignes access mode. Can somebody elaborate this with the Windows team? Is this to be expected, and if so, is there any other way I can wake the display from a UWP in assigned access mode?

Thank you very much in advance!

Kind regards
Richard

windows-uwp
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RichardBraun-6902 You mentioned that you could use InputInjection successfully in the assigned access mode. What is the input? Could you please try other InjectedInputMouseOptions(such as LeftDown, LeftUp) to wake up display in assigned access mode?

0 Votes 0 ·

Thank you very much for your comment!
I have tried to inject scrolling (mouse wheel) as shown in the code above as well as touch input (tapping the screen), moving the pointer and clicking.
Testing assigned access mode, it seems as if the app is unloaded (suspended) as soon as the display turns off, whicht would explain the problem. I am registering a ExtendedExecutionForegroundSession, which again works fine on my regular user account, but seems to get ignored by assigned acces.

0 Votes 0 ·

I was able to reproduce the problem in a test app. ExtendedExecutionForegroundSessions do not work when the screen is off in assigned access mode. This is why the application cannot wake the system by input injection. Is there any way to fix this?

0 Votes 0 ·

@RichardBraun-6902 We are consulting other engineers for your question. There may be some delay.

0 Votes 0 ·
Show more comments

0 Answers