1import mouse
2import time
3import os
4while True:
5 before_sleep = mouse.get_position()
6 time.sleep(600)#depends on you
7 after_sleep = mouse.get_position()
8 if before_sleep == after_sleep:
9 os.system("shutdown /s /t 1")
10#you can make your own detection to find if user is using keyboard