Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello experts, i am looking for solution how to unlock screen in windows using c#, i have used AdminAutoLogin in registry but it does not serve the purpose, it only logins computer at startup. I want my app to check if screen is locked so it will simply unlock it. is there any windows api or any dll where i can trigger this. Help would be much appreciated.
thanks.

What I have tried:

i am binding this event so i can check the current state of windows.
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
which i am achieving successfully, now i need to unlock it programmatically.
Posted
Updated 16-Nov-21 20:26pm

1 solution

You can't: the screen lock is a security feature which requires the user to unlock it using the method(s) he has selected (PIN, Windows Hello, whatever) and that cannot be "bypassed" at will by any application.

Imaging it was possible: how useful would that feature be to malicious code / coders? Want to access your bosses computer? Add code to the company app which unlocks his computer while he is at lunch ...

You can't do it.
 
Share this answer
 
Comments
Arsalan Khan 2 17-Nov-21 2:28am    
what if there is no password on the user account? can we do that ?
OriginalGriff 17-Nov-21 3:14am    
No, because "no password" is a user setting: they then have to "swipe up" to unlock.
Screen locking is a security feature: apps can't unlock it!

What are you trying to do that you think you need this?
Arsalan Khan 2 17-Nov-21 3:19am    
i just need a simple app which will be running in the background and when computer is locked it will calculate time after locking and then it will simply unlock it after certain time. this is requirement for windows 10
OriginalGriff 17-Nov-21 3:29am    
Go to amazon, and search for "mouse jiggler" - it's a cheap device which just moves the mouse slightly every now and then to prevent inactivity locking it.
Ravi Bhavnani 17-Nov-21 13:10pm    
...or write your own. :)

http://frasergreenroyd.com/mouse-jiggle-tool-create-your-own-in-c/

/ravi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900