#!/usr/bin/env python3 """ Test the fixed mouse movement detection logic """ import sys import os import time # Add src directory to path sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'src')) from mouse_mover import MouseMover from logging_config import setup_logging, get_logger def test_fixed_mouse_logic(): """Test the updated mouse movement logic""" setup_logging(debug=True) logger = get_logger(__name__) print("🧪 Testing Fixed Mouse Movement Logic") print("========================================") print("This should now behave like your original mouse.py script") print("- Mouse movement should reset the timer immediately") print("- Uses the same OR logic: (x == xold or y == yold)") print("- Only updates yold, keeps xold at 0") print("") print("Starting with 30-second timer for testing...") print("Move your mouse to test timer reset") print("Press Ctrl+C to stop") print("") # Create mouse mover with short wait time for testing mouse_mover = MouseMover(wait_time=30, move_px=15) # 30 second wait for testing try: mouse_mover.start() # Let it run and monitor for i in range(60): # Run for 1 minute max status = mouse_mover.get_status() print(f"⏱️ Time: {i:2d}s, Countdown: {status['countdown']:2d}s, Running: {status['running']}") time.sleep(1) # If countdown gets very low, the user isn't moving the mouse if status['countdown'] <= 5: print("🔥 Timer about to expire! Move your mouse to reset it!") except KeyboardInterrupt: print("\n⏹️ Test interrupted by user") finally: mouse_mover.stop() print("✅ Test completed!") print("") print("If timer reset properly when you moved the mouse, the fix is working!") if __name__ == "__main__": test_fixed_mouse_logic()