Console/terminal demo of keyboard automation with pyautogui, supporting Windows 11 and Ubuntu Linux 24.04. The demo optionally opens the system text editor (Notepad on Windows), counts down so you have time to focus the window you want, clicks once, types a line of text followed by Enter, and can also send the save shortcut. A desktop session is required, because the script injects real keystrokes into whatever window has focus — it is not typing into its own terminal.
[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 types into a live window and writes nothing to disk.
[Prerequisites]
- Operating system: Windows 11 or Ubuntu Linux 24.04.
- Python 3 and pip.
- A desktop session: the demo sends real keystrokes to the focused window, 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 keyboard automation demo
The demo opens the text editor, counts down, then clicks and types. While the countdown runs, click the window you want the text to go into. Extra arguments are forwarded to the Python script.
Windows 11: src\03_keyboard.bat
Ubuntu 24.04: bash src/03_keyboard.sh
Your own text, typed into a window you focus yourself:
bash src/03_keyboard.sh --no-editor --text "Hello LEADERG!" --delay 5
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/keyboard_demo.py: [--text "Hello World!!"] [--interval 0.5] [--delay 10] [--no-editor] [--save].
- --text: the line to type, "Hello World!!" by default.
- --interval: the delay between keystrokes in seconds, default 0.5, so you can watch the typing happen.
- --delay: how many seconds to count down before typing, default 10. Use the countdown to focus the target window.
- --no-editor: skip opening the text editor and type into whatever you focus yourself. Without it the demo opens the platform's editor (Notepad, TextEdit or a gedit-family editor).
- --save: also send Ctrl+S after typing (Cmd+S on macOS).
- The keystrokes go to whichever window has focus when the countdown ends, so make sure the right window is in front.
[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 keystrokes never reach other applications.
[References]
- pyautogui keyboard documentation: pyautogui.readthedocs.io/en/latest/keyboard.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.