The easiest way to lock Windows is by pressing Windows+L combinations. But, that process could be automated.
In this guide, you will learn how to automatically lock Windows when not in use (idle) for a specific time. That way, other people won’t be able to access your PC.
1. Go to Start Menu and find Local Security Policy.

2. Expand the Local Policies menu and select Security Options.

3. On the right side, navigate to Interactive logon: Machine inactivity limit, right-click on it and select Properties.

4. Set the time, click OK to confirm.

5. Finally, restart the PC to take the effect.

Your PC will lock itself after there’s no activity for a certain duration. Don’t worry, it won’t be locked when doing passive activities like watching videos, installing programs, or downloading files.