Skip to content
TheChatArchiveThe Chat Archive
chatgpt-4o-latest-20250326· OpenAIHugging Face LMArena Human Preference 140K

Write a python script that moves mouse down right, then down left, then upleft, then up…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen-max-2025-01-25’s answer.
  1. User

    Write a python script that moves mouse down right, then down left, then upleft, then up right, so it is back to starting position.

  2. Assistant

    Of course! Here's a Python script that moves the mouse in the pattern you described:

    import pyautogui
    import time
    
    # Set the distance to move in each direction
    distance = 100  # pixels
    duration = 0.5  # seconds for each move
    
    # Give user time to move mouse to starting position
    print("Starting in 3 seconds. Move your mouse to the starting position.")
    time.sleep(3)
    
    # Move down-right
    pyautogui.moveRel(distance, distance, duration=duration)
    
    # Move down-left
    pyautogui.moveRel(-distance, distance, duration=duration)
    
    # Move up-left
    pyautogui.moveRel(-distance, -distance, duration=duration)
    
    # Move up-right
    pyautogui.moveRel(distance, -distance, duration=duration)
    
    print("Done!")
    

    ✅ Explanation:

    • pyautogui.moveRel(x, y, duration) moves the mouse relative to its current position.
    • Positive x moves right, positive y moves down.
    • Negative x moves left, negative y moves up.
    • The script moves:
      1. Down and right
      2. Down and left
      3. Up and left
      4. Up and right
    • Ending back at the starting point.

    Requirements:

    Install pyautogui if you haven't already:

    pip install pyautogui
    

    ⚠️ Warning: Be careful when automating mouse movements, especially if you run scripts that move the mouse indefinitely. Always have a way to interrupt (e.g., move mouse to a corner to trigger pyautogui.FAILSAFE).


    Would you also like a version that draws a smooth square or diamond shape instead of just straight lines? 🎨

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.