1

I have been searching for a while for how to trigger a screen lock on windows programmatically from a UWP app, but the only thing found from MSDN is this and it doesn't even trigger a lock screen event. It creates a new lock screen. My use case is this: I verify users via a UWP i have developed. If for one user the verification fails, i want to trigger the PC lock for this user.

Is this even possible through a UWP?

Thank you in advance!

esmehsnj
  • 162
  • 2
  • 17

1 Answers1

0

Currently, there is no such api that could take over lock screen within uwp platform. For Windows.ApplicationModel.LockScreen api that is use to let your app show an indicator on the lock screen, not for taking over the lock screen. For more info please refer link here.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • Thank you for the information! The other option i can think of is programmatically create an event that would simulate pressing Windows button + L button in keyboard in UWP. Is this possible in UWP? I know it can be done in wpf – esmehsnj Nov 12 '20 at 10:11
  • Sure, you could injecting input in uwp, for more please research Martin's blog **Injecting input in UWP apps** – Nico Zhu Nov 13 '20 at 01:16
  • I used win + l with injecting before, unfortunately, it will not lock the system. – Nico Zhu Nov 13 '20 at 09:53