Console/terminal demo of mouse automation with pyautogui, supporting Windows 11 and Ubuntu Linux 24.04. The demo prints the screen size and the current pointer position, optionally performs a right click and a left click, moves the pointer to the centre of the screen, and then traces a square using relative moves. A desktop session is required, because the script moves the real pointer rather than simulating one inside its own window.
[Folder Structure]
- CLAUDE.md / AGENT.md: program specification (identical content).
- CHANGELOG.md: change log.
- copyright.txt: copyright notice.
- tool/tools.py: shared helpers.
- src/: the demo, the launcher scripts and this document.
- venv/: Python virtual environment, created by step 1.
There are no data/ or model/ folders, because the demo moves the live pointer and writes nothing to disk.
[Prerequisites]
- Operating system: Windows 11 or Ubuntu Linux 24.04.
- Python 3 and pip.
- A desktop session: the demo controls the real pointer, so it cannot run headless or over a plain SSH connection.
- Dependencies (pyautogui) are listed in src/requirements.txt and installed by step 1.
- No GPU required.
[Instructions]
Step 1: create the virtual environment
Delete the old venv/, create a fresh one and install src/requirements.txt (pyautogui). Aborts loudly if pip fails.
Windows 11: src\01_venv_create.bat
Ubuntu 24.04: bash src/01_venv_create.sh
Step 2: activate the virtual environment
Activate the venv you just created. On Linux, source it so the environment variables apply to the current shell.
Windows 11: src\02_venv_activate.bat
Ubuntu 24.04: source src/02_venv_activate.sh
Step 3: run the mouse automation demo
The demo clicks at the current position, moves to the centre of the screen and traces a square. Extra arguments are forwarded to the Python script.
Windows 11: src\03_mouse.bat
Ubuntu 24.04: bash src/03_mouse.sh
Movement only, with a larger square:
bash src/03_mouse.sh --no-click --square-size 200 --loops 1
Step 4: clear the virtual environment (optional)
Delete the venv/ folder to free disk space when you no longer need it.
Windows 11: src\99_venv_clear.bat
Ubuntu 24.04: bash src/99_venv_clear.sh
[Python Entry Point]
- src/mouse_demo.py: [--square-size 100] [--loops 3] [--move-duration 0.2] [--no-click].
- --square-size: the side length of the traced square in pixels, default 100.
- --loops: how many times to trace the square, default 3.
- --move-duration: how long each move takes in seconds, default 0.2, which makes the motion visible instead of instant.
- --no-click: skip the right and left clicks and only move the pointer.
- The clicks land on whatever happens to be under the pointer, so use --no-click if that is not what you want.
[Usage Notes]
- On Linux, pyautogui needs an X11 display. Under Wayland, run it through XWayland or log into an Xorg session.
- On macOS, grant the terminal the Accessibility permission, otherwise the pointer control does not work.
[References]
- pyautogui mouse documentation: pyautogui.readthedocs.io/en/latest/mouse.html
This SDK is built in AppForAI - AI Dev Tools.
Purchase license separately: USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.