Windows Key + R and type: regedit and click OK
Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
Now create a new 32-bit DWORD Value called InactivityTimeoutSecs and give it a value between 0 or 599940 – again, that is the number of seconds of inactivity you want to pass before locking your system.
Then sign out of your session or restart your PC for the settings to go into effect.