A powerful Python-based automation tool for macOS that enables window control, mouse/keyboard automation, and action recording.
- Window Management: Find, focus, and control specific application windows
- Action Recording: Record mouse clicks, keyboard input, and other user interactions
- Coordinate Helper: Interactive coordinate recording with color detection
- JSON Configuration: Define complex automation workflows using JSON files
- Relative Positioning: Support for both absolute and window-relative coordinates
- Conditional Logic: Wait for colors, windows, or time-based conditions
- Loop Support: Execute repetitive tasks with various loop types
- Screenshot Capabilities: Capture screens for analysis or error debugging
- macOS (uses native Quartz and AppKit frameworks)
- Python 3.6 or higher
- Required Python packages (see requirements.txt)
pip install mactorobrew tap kory-/mactoro
brew install mactorogit clone https://github.com/kory-/mactoro.git
cd mactoro
pip install -e .- Grant accessibility permissions:
- Go to System Preferences → Security & Privacy → Privacy → Accessibility
- Add Terminal (or your Python interpreter) to the allowed applications
Mactoro uses a hierarchical command structure:
mactoro <command> <subcommand> [options]
mactoro window listmactoro action record --window "TextEdit" --output recording.jsonOptions:
--window-id, -i: Use window ID instead of name--no-merge: Don't merge consecutive similar actions--record-mouse-move: Also record mouse movements
mactoro action run --window "Chrome" --config my_automation.jsonOptions:
--window, -w: Target window name--window-id, -i: Target window ID--config, -c: Configuration file path (required)--coordinates: Coordinates definition file--debug, -d: Enable debug mode
mactoro coordinate record --window "Finder"mactoro coordinate capture --window "Safari" --analyzemactoro coordinate analyze --image screenshot.pngmactoro generate-config --coordinates coords.json --output config.json{
"settings": {
"default_wait": 0.5,
"screenshot_on_error": true,
"max_runtime": 3600
},
"actions": [
{
"type": "click",
"x": 100,
"y": 200,
"wait": 1
}
]
}{
"type": "click",
"x": 100,
"y": 200,
"relative_to": "window",
"wait": 0.5
}{
"type": "type",
"text": "Hello World",
"interval": 0.05
}{
"type": "hotkey",
"keys": ["cmd", "c"]
}{
"type": "wait",
"seconds": 2
}{
"type": "wait_for_color",
"x": 150,
"y": 250,
"color": [0, 122, 255],
"tolerance": 10,
"timeout": 5
}{
"type": "loop",
"max_iterations": 10,
"actions": [
{
"type": "click",
"x": 100,
"y": 100
}
]
}{
"type": "loop_until",
"condition": {
"type": "color_match",
"x": 500,
"y": 300,
"color": [255, 0, 0],
"tolerance": 10
},
"timeout": 60,
"actions": [
{
"type": "click",
"x": 400,
"y": 400
}
]
}{
"settings": {
"default_wait": 0.5
},
"actions": [
{
"type": "click",
"x": 300,
"y": 200,
"relative_to": "window",
"comment": "Click username field"
},
{
"type": "type",
"text": "john.doe@example.com"
},
{
"type": "click",
"x": 300,
"y": 250,
"relative_to": "window",
"comment": "Click password field"
},
{
"type": "type",
"text": "password123"
},
{
"type": "click",
"x": 350,
"y": 300,
"relative_to": "window",
"comment": "Click submit button"
}
]
}- First, record the actions:
mactoro action record --window "MyApp" --output my_recording.json- The tool will create a JSON file with all recorded actions
- Run the recorded automation:
mactoro action run --window "MyApp" --config my_recording.json- Record specific coordinates:
mactoro coordinate record --window "Calculator"- Generate config template from coordinates:
mactoro generate-config --coordinates coordinates.json --output calc_automation.json- Edit the generated config and run:
mactoro action run --window "Calculator" --config calc_automation.jsonThe new unified command structure:
mactoro window list # List all windows
mactoro action record [options] # Record actions
mactoro action run [options] # Run automation
mactoro coordinate record [options] # Record coordinates
mactoro coordinate capture [options] # Capture screenshot
mactoro coordinate analyze [options] # Analyze image
mactoro generate-config [options] # Generate config
-
Use Window-Relative Coordinates: Always prefer
"relative_to": "window"for better reliability across different screen positions -
Add Wait Times: Use appropriate wait times between actions to ensure UI elements are ready
-
Error Handling: Enable
"screenshot_on_error": trueto capture the screen state when errors occur -
Test in Debug Mode: Use
--debugflag to see detailed execution information -
ESC to Stop: Press ESC key anytime during execution to safely stop the automation
-
"Window not found" error
- Ensure the window is open and visible
- Try using partial window name matching
- Use
listcommand to see exact window names
-
Permission denied errors
- Grant accessibility permissions in System Preferences
- Run Terminal with appropriate permissions
-
Coordinates not working
- Verify window position hasn't changed
- Use window-relative coordinates instead of absolute
- Re-record coordinates if necessary
MIT License
Copyright (c) 2024
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.