I created a script for work that logs the idle time every 5 minutes. It was created to check if a computer somehow gets locked even though it wasn't inactive for a long time.
Please don't use this code to spy on your employees, as maybe people work without using the computer or are in meetings.