Auto Move Mouse Using Python Script for Time Tracking

Many companies now use productivity monitoring tools that track mouse and keyboard activity. With Cognizant introducing an idle time tracker that marks employees inactive after 5 minutes, many remote workers are now searching for ways to bypass idle detection because genuine thinking time often gets counted as idle time.

To test this behaviour, I created a simple Python mouse jiggler script that makes small movements and key actions to keep the system active. It prevents the idle status without affecting real work and acts as an easy workaround for strict activity tracking tools.

The Python Script I Created to Avoid Being Marked Idle

✓ Runs every 30 seconds
✓ Works on Windows and macOS
✓ Prevents idle tracking software from marking you away


import time
import pyautogui
import schedule
import random
import platform

OS = platform.system().lower()
DRAG_BUTTON = 'left' if OS == 'darwin' else None


def func():
    pyautogui.moveTo(1000, 1000, duration=1)

    if DRAG_BUTTON:
        pyautogui.dragRel(0, -100, duration=1, button=DRAG_BUTTON)
    else:
        pyautogui.dragRel(0, -100, duration=1)

    pyautogui.scroll(200, 500)
    pyautogui.moveTo(100, 100, duration=2)
    if OS == "darwin":
        alt_key = "option"
    else:
        alt_key = "alt"

    pyautogui.keyDown(alt_key)
    time.sleep(0.2)
    pyautogui.press("tab")
    time.sleep(0.2)
    pyautogui.press("tab")
    time.sleep(0.2)
    pyautogui.keyUp(alt_key)


schedule.every(0.5).minutes.do(func)

while True:
    schedule.run_pending()
    time.sleep(0.5)

  

Prerequisites

  1. Python 3 installed on your system
  2. pip or pip3 installed (comes with most Python installations)
  3. Install required packages using: pip3 install pyautogui schedule
  4. Permission to allow automated mouse and keyboard control (needed on macOS)

How to use this script?

  1. Install required packages: -> pip3 install pyautogui schedule (Make sure you have python3 and pip installed)
  2. Copy this script and save it in your device as “.py” extension. You can name it like example.py or keep it simply like “.py” only which will hide this automatically, as some devices hides file which starts with dot.
  3. Now run the script like python3 filename.py
  4. Please watch below video if you did not understand.

Why I Wrote This Blog

I wanted to explain:

  • How modern employee tracking works
  • Why many employees dislike activity based monitoring
  • How simple automation can avoid unnecessary issues
  • How a small Python script can help beginners learn automation concepts

Apart from preventing idle time, scripts like this are a fun way to explore Python and understand how your system reacts to user activity.

My opinion

Tools that track only mouse and keyboard input do not reflect real productivity. Real work involves thinking, planning, analysing, and solving problems, not constant clicking.

Until companies adopt better and more trust based working models, simple automation tricks will always exist.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top