# Peekabooβ€”screenshot got you! Now you see it, now it's saved. ![Peekaboo Banner](assets/banner.png) πŸ‘€ β†’ πŸ“Έ β†’ πŸ’Ύ β€” **Unattended screenshot automation that actually works** --- ## πŸš€ **THE MAGIC** **Peekaboo** is your silent screenshot assassin. Point it at any app, and SNAP! β€” it's captured and saved before you can blink. - 🎯 **Smart targeting**: App names or bundle IDs - πŸš€ **Auto-launch**: Sleeping apps? No problem! - πŸ‘ **Brings apps forward**: Always gets the shot - πŸ— **Creates directories**: Paths don't exist? Fixed! - 🎨 **Multi-format**: PNG, JPG, PDF β€” you name it - πŸ’₯ **Zero interaction**: 100% unattended operation - 🧠 **Smart filenames**: Model-friendly names with app info - ⚑ **Optimized speed**: 70% faster capture delays - πŸ€– **AI Vision Analysis**: Local Ollama integration with auto-model detection - ☁️ **Cloud AI Ready**: Self-documenting for Claude, Windsurf, ChatGPT integration --- ## πŸŽͺ **HOW TO USE** ### 🎯 **Basic Usage** *Simple screenshot capture* ```bash # πŸ‘€ Quick shot with smart filename osascript peekaboo.scpt "Safari" # β†’ /tmp/peekaboo_safari_20250522_143052.png # 🎯 Custom output path osascript peekaboo.scpt "Safari" "/Users/you/Desktop/safari.png" # 🎯 Bundle ID targeting osascript peekaboo.scpt "com.apple.TextEdit" "/tmp/textedit.jpg" ``` ### πŸŽͺ **Advanced Features** *All the power. All the windows. All the time.* ```bash # πŸ” What's running right now? osascript peekaboo.scpt list # πŸ‘€ Quick shot to /tmp with timestamp osascript peekaboo.scpt "Chrome" # 🎭 Capture ALL windows with smart names osascript peekaboo.scpt "Chrome" "/tmp/chrome.png" --multi # πŸͺŸ Just the front window osascript peekaboo.scpt "TextEdit" "/tmp/textedit.png" --window # πŸ€– AI analysis: Screenshot + question in one step osascript peekaboo.scpt "Safari" --ask "What's on this page?" # πŸ” Analyze existing image osascript peekaboo.scpt analyze "/tmp/screenshot.png" "Any errors visible?" ``` --- ## ⚑ **QUICK WINS** ### 🎯 **Basic Shot** ```bash # Quick shot with auto-generated filename osascript peekaboo.scpt "Finder" ``` **Result**: Full screen with Finder in focus β†’ `/tmp/peekaboo_finder_20250522_143052.png` *Notice the smart filename: app name + timestamp, all lowercase with underscores* ```bash # Custom path osascript peekaboo.scpt "Finder" "/Desktop/finder.png" ``` **Result**: Full screen with Finder in focus β†’ `finder.png` ### 🎭 **Multi-Window Magic** ```bash osascript peekaboo.scpt "Safari" "/tmp/safari.png" --multi ``` **Result**: Multiple files with smart names: - `safari_window_1_github.png` - `safari_window_2_documentation.png` - `safari_window_3_google_search.png` ### πŸ” **App Discovery** ```bash osascript peekaboo.scpt list ``` **Result**: Every running app + window titles. No guessing! --- ## πŸ›  **SETUP** ### 1️⃣ **Make Executable** ```bash chmod +x peekaboo.scpt ``` ### 2️⃣ **Grant Powers** - System Preferences β†’ Security & Privacy β†’ **Screen Recording** - Add your terminal app to the list - ✨ You're golden! --- ## 🎨 **FORMAT PARTY** Peekaboo speaks all the languages: ```bash # PNG (default) - smart filename in /tmp osascript peekaboo.scpt "Safari" # β†’ /tmp/peekaboo_safari_20250522_143052.png # PNG with custom path osascript peekaboo.scpt "Safari" "/tmp/shot.png" # JPG - smaller files osascript peekaboo.scpt "Safari" "/tmp/shot.jpg" # PDF - vector goodness osascript peekaboo.scpt "Safari" "/tmp/shot.pdf" ``` --- ## πŸ€– **AI VISION ANALYSIS** ⭐ Peekaboo integrates with **Ollama** for powerful local AI vision analysis - ask questions about your screenshots! No cloud, no API keys, just pure local magic. ### 🎯 **Key Features** - **🧠 Smart Model Auto-Detection** - Automatically picks the best available vision model - **πŸ“ Intelligent Image Resizing** - Auto-compresses large screenshots (>5MB β†’ 2048px) for optimal AI processing - **⚑ One or Two-Step Workflows** - Screenshot+analyze or analyze existing images - **πŸ”’ 100% Local & Private** - Everything runs on your machine via Ollama - **🎯 Zero Configuration** - Just install Ollama + model, Peekaboo handles the rest ### πŸš€ **One-Step: Screenshot + Analysis** ```bash # Take screenshot and analyze it in one command osascript peekaboo.scpt "Safari" --ask "What's the main content on this page?" osascript peekaboo.scpt "Terminal" --ask "Any error messages visible?" osascript peekaboo.scpt "Xcode" --ask "Is the build successful?" osascript peekaboo.scpt "Chrome" --ask "What product is being shown?" --model llava:13b # Fullscreen analysis (no app targeting needed) osascript peekaboo.scpt --ask "Describe what's on my screen" osascript peekaboo.scpt --verbose --ask "Any UI errors or warnings visible?" ``` ### πŸ” **Two-Step: Analyze Existing Images** ```bash # Analyze screenshots you already have osascript peekaboo.scpt analyze "/tmp/screenshot.png" "Describe what you see" osascript peekaboo.scpt analyze "/path/error.png" "What error is shown?" osascript peekaboo.scpt analyze "/Desktop/ui.png" "Any UI issues?" --model qwen2.5vl:7b ``` ### πŸ› οΈ **Complete Ollama Setup Guide** #### 1️⃣ **Install Ollama** ```bash # macOS (Homebrew) brew install ollama # Or direct install curl -fsSL https://ollama.ai/install.sh | sh # Or download from https://ollama.ai ``` #### 2️⃣ **Start Ollama Service** ```bash # Start the service (runs in background) ollama serve # Or use the Ollama.app (GUI version) # Download from https://ollama.ai β†’ Double-click to install ``` #### 3️⃣ **Pull Vision Models** ```bash # πŸ† Recommended: Best overall (6GB) ollama pull qwen2.5vl:7b # πŸš€ Popular choice: Good balance (4.7GB) ollama pull llava:7b # ⚑ Lightweight: Low RAM usage (2.9GB) ollama pull llava-phi3:3.8b # πŸ” OCR specialist: Great for text (5.5GB) ollama pull minicpm-v:8b # 🌍 Latest and greatest: Cutting edge (11GB) ollama pull llama3.2-vision:11b ``` #### 4️⃣ **Verify Setup** ```bash # Check running models ollama list # Test vision analysis osascript peekaboo.scpt --ask "What do you see on my screen?" ``` ### 🧠 **Smart Model Selection** Peekaboo automatically picks the best available vision model in priority order: | Model | Size | Strengths | Best For | |-------|------|-----------|----------| | **qwen2.5vl:7b** | 6GB | πŸ† Document/chart analysis | Technical screenshots, code, UI | | **llava:7b** | 4.7GB | πŸš€ Well-rounded performance | General purpose, balanced usage | | **llava-phi3:3.8b** | 2.9GB | ⚑ Fast & lightweight | Low-resource systems, quick analysis | | **minicpm-v:8b** | 5.5GB | πŸ” Superior OCR accuracy | Text-heavy images, error messages | | **llama3.2-vision:11b** | 11GB | 🌟 Latest technology | Best quality, high-end systems | ### πŸ“ **Smart Image Processing** Peekaboo automatically optimizes images for AI analysis: ```bash # Large screenshots (>5MB) are automatically compressed πŸ” Image size: 7126888 bytes πŸ” Image is large (7126888 bytes), creating compressed version for AI # β†’ Resized to 2048px max dimension while preserving aspect ratio # β†’ Maintains quality while ensuring fast AI processing ``` **Benefits:** - βœ… **Faster Analysis** - Smaller images = quicker AI responses - βœ… **Reliable Processing** - Avoids API timeouts with huge images - βœ… **Preserves Originals** - Full-resolution screenshots remain untouched - βœ… **Smart Compression** - Uses macOS native `sips` tool for quality resizing ### πŸ’‘ **Pro Usage Examples** ```bash # Automated UI testing with smart resizing osascript peekaboo.scpt "Your App" --ask "Any error dialogs or crashes visible?" # High-resolution dashboard analysis (auto-compressed for AI) osascript peekaboo.scpt "Grafana" --ask "Are all metrics healthy and green?" # Detailed code review screenshots osascript peekaboo.scpt "VS Code" --ask "Any syntax errors or warnings in the code?" # Large-screen analysis (automatically handles 4K+ displays) osascript peekaboo.scpt --ask "Describe the overall layout and any issues" ``` **Perfect for:** - πŸ§ͺ **Automated UI Testing** - "Any error messages visible?" - πŸ“Š **Dashboard Monitoring** - "Are all systems green?" - πŸ› **Error Detection** - "What errors are shown in this log?" - πŸ“Έ **Content Verification** - "Does this page look correct?" - πŸ” **Visual QA Automation** - "Any broken UI elements?" - πŸ“± **App State Verification** - "Is the login successful?" --- ## ☁️ **CLOUD AI INTEGRATION** Peekaboo works seamlessly with **any AI service** that can read files! Perfect for Claude Code, Windsurf, ChatGPT, or any other AI tool. ### πŸš€ **Quick Cloud AI Setup** **For AI tools like Claude Code, Windsurf, etc.:** 1. **Copy the script file** to your project directory: ```bash cp peekaboo.scpt /path/to/your/project/ ``` 2. **Tell your AI tool about it**: ``` I have a screenshot automation tool called peekaboo.scpt in this directory. It can capture screenshots of any app and save them automatically. Please read the file to understand how to use it. ``` 3. **Your AI will automatically understand** how to: - Take screenshots of specific apps - Use smart filenames with timestamps - Capture multiple windows - Handle different output formats - Integrate with your workflow ### πŸ’‘ **Example AI Prompts** ```bash # Ask your AI assistant: "Use peekaboo.scpt to take a screenshot of Safari and save it to /tmp/webpage.png" "Capture all Chrome windows with the multi-window feature" "Take a screenshot of Xcode and then analyze if there are any build errors visible" "Set up an automated screenshot workflow for testing my app" ``` ### 🎯 **AI Tool Integration Examples** **Claude Code / Windsurf:** ``` Use the peekaboo.scpt tool to capture screenshots during our development session. The script automatically handles app targeting, file paths, and smart naming. ``` **ChatGPT / GitHub Copilot:** ``` I have a screenshot automation script. Please read peekaboo.scpt and help me integrate it into my testing workflow. ``` **Custom AI Scripts:** ```python import subprocess def take_screenshot(app_name, output_path): """Use Peekaboo to capture app screenshots""" cmd = ["osascript", "peekaboo.scpt", app_name, output_path] return subprocess.run(cmd, capture_output=True, text=True) # Your AI can now use this function automatically! ``` ### 🧠 **Why AI Tools Love Peekaboo** - **πŸ“– Self-Documenting**: AI reads the script and understands all features instantly - **🎯 Zero Config**: No API keys, no setup - just works - **🧠 Smart Outputs**: Model-friendly filenames make AI integration seamless - **⚑ Reliable**: Unattended operation perfect for AI-driven workflows - **πŸ” Comprehensive**: From basic screenshots to multi-window analysis **The AI tool will automatically discover:** - All available command-line options (`--multi`, `--window`, `--verbose`) - Smart filename generation patterns - Error handling and troubleshooting - Integration with local Ollama for AI analysis - Testing capabilities and examples ### πŸŽͺ **Cloud AI + Local AI Combo** **Powerful workflow example:** ```bash # 1. Use Peekaboo to capture and analyze locally osascript peekaboo.scpt "Your App" --ask "Any errors visible?" # 2. Your cloud AI assistant can read the results and provide guidance # 3. Iterate and improve based on AI recommendations # 4. Automate the entire process with AI-generated scripts ``` --- ## 🧠 **SMART FILENAMES** Peekaboo automatically generates **model-friendly** filenames that are perfect for automation: ```bash # App names become lowercase with underscores osascript peekaboo.scpt "Safari" β†’ peekaboo_safari_TIMESTAMP.png osascript peekaboo.scpt "Activity Monitor" β†’ peekaboo_activity_monitor_TIMESTAMP.png osascript peekaboo.scpt "com.apple.TextEdit" β†’ peekaboo_com_apple_textedit_TIMESTAMP.png osascript peekaboo.scpt "Final Cut Pro" β†’ peekaboo_final_cut_pro_TIMESTAMP.png # Multi-window gets descriptive names osascript peekaboo.scpt "Chrome" --multi β†’ chrome_window_1_github.png β†’ chrome_window_2_documentation.png ``` **Perfect for:** - πŸ€– AI model file references - πŸ“ Scripting and automation - πŸ” Easy file searching - πŸ“Š Batch processing --- ## πŸ† **POWER MOVES** ### 🎯 **Targeting Options** ```bash # By name (easy) - smart filename osascript peekaboo.scpt "Safari" # β†’ /tmp/peekaboo_safari_20250522_143052.png # By name with custom path osascript peekaboo.scpt "Safari" "/tmp/safari.png" # By bundle ID (precise) - gets sanitized osascript peekaboo.scpt "com.apple.Safari" # β†’ /tmp/peekaboo_com_apple_safari_20250522_143052.png # By display name (works too!) - spaces become underscores osascript peekaboo.scpt "Final Cut Pro" # β†’ /tmp/peekaboo_final_cut_pro_20250522_143052.png ``` ### πŸŽͺ **Pro Features** ```bash # Multi-window capture --multi # All windows with descriptive names # Window modes --window # Front window only (unattended!) # Debug mode --verbose # See what's happening under the hood ``` ### πŸ” **Discovery Mode** ```bash osascript peekaboo.scpt list ``` Shows you: - πŸ“± All running apps - πŸ†” Bundle IDs - πŸͺŸ Window counts - πŸ“ Exact window titles --- ## 🎭 **REAL-WORLD SCENARIOS** ### πŸ“Š **Documentation Screenshots** ```bash # Quick capture to /tmp osascript peekaboo.scpt "Xcode" --multi osascript peekaboo.scpt "Terminal" --multi osascript peekaboo.scpt "Safari" --multi # Capture your entire workflow with custom paths osascript peekaboo.scpt "Xcode" "/docs/xcode.png" --multi osascript peekaboo.scpt "Terminal" "/docs/terminal.png" --multi osascript peekaboo.scpt "Safari" "/docs/browser.png" --multi ``` ### πŸš€ **CI/CD Integration** ```bash # Quick automated testing screenshots with smart names osascript peekaboo.scpt "Your App" # β†’ /tmp/peekaboo_your_app_20250522_143052.png # Automated visual testing with AI osascript peekaboo.scpt "Your App" --ask "Any error messages or crashes visible?" osascript peekaboo.scpt "Your App" --ask "Is the login screen displayed correctly?" # Custom path with timestamp osascript peekaboo.scpt "Your App" "/test-results/app-$(date +%s).png" ``` ### 🎬 **Content Creation** ```bash # Before/after shots with AI descriptions osascript peekaboo.scpt "Photoshop" --ask "Describe the current design state" # ... do your work ... osascript peekaboo.scpt "Photoshop" --ask "What changes were made to the design?" # Traditional before/after shots osascript peekaboo.scpt "Photoshop" "/content/before.png" # ... do your work ... osascript peekaboo.scpt "Photoshop" "/content/after.png" ``` ### πŸ§ͺ **Automated QA & Testing** ```bash # Visual regression testing osascript peekaboo.scpt "Your App" --ask "Does the UI look correct?" osascript peekaboo.scpt "Safari" --ask "Are there any broken images or layout issues?" osascript peekaboo.scpt "Terminal" --ask "Any red error text visible?" # Dashboard monitoring osascript peekaboo.scpt analyze "/tmp/dashboard.png" "Are all metrics green?" ``` --- ## 🚨 **TROUBLESHOOTING** ### πŸ” **Permission Denied?** - Check Screen Recording permissions - Restart your terminal after granting access ### πŸ‘» **App Not Found?** ```bash # See what's actually running osascript peekaboo.scpt list # Try the bundle ID instead osascript peekaboo.scpt "com.company.AppName" "/tmp/shot.png" ``` ### πŸ“ **File Not Created?** - Check the output directory exists (Peekaboo creates it!) - Verify disk space - Try a simple `/tmp/test.png` first ### πŸ› **Debug Mode** ```bash osascript peekaboo.scpt "Safari" "/tmp/debug.png" --verbose ``` --- ## πŸŽͺ **FEATURES** | Feature | Description | |---------|-------------| | **Basic screenshots** | βœ… Full screen capture with app targeting | | **App targeting** | βœ… By name or bundle ID | | **Multi-format** | βœ… PNG, JPG, PDF support | | **App discovery** | βœ… `list` command shows running apps | | **Multi-window** | βœ… `--multi` captures all app windows | | **Smart naming** | βœ… Descriptive filenames for windows | | **Window modes** | βœ… `--window` for front window only | | **Auto paths** | βœ… Optional output path with smart /tmp defaults | | **Smart filenames** | βœ… Model-friendly: app_name_timestamp format | | **AI Vision Analysis** | βœ… Local Ollama integration with auto-model detection | | **Smart AI Models** | βœ… Auto-picks best: qwen2.5vl > llava > phi3 > minicpm | | **Smart Image Compression** | βœ… Auto-resizes large images (>5MB β†’ 2048px) for AI | | **Cloud AI Integration** | βœ… Self-documenting for Claude, Windsurf, ChatGPT, etc. | | **Verbose logging** | βœ… `--verbose` for debugging | --- ## πŸ§ͺ **TESTING** We've got you covered with comprehensive testing: ```bash # Run the full test suite ./test_peekaboo.sh # Test specific features ./test_peekaboo.sh ai # AI vision analysis only ./test_peekaboo.sh advanced # Multi-window, discovery, AI ./test_peekaboo.sh basic # Core screenshot functionality ./test_peekaboo.sh quick # Essential tests only # Test and cleanup ./test_peekaboo.sh all --cleanup ``` **Complete Test Coverage:** - βœ… Basic screenshots with smart filenames - βœ… App resolution (names + bundle IDs) - βœ… Format support (PNG, JPG, PDF) - βœ… Multi-window scenarios with descriptive names - βœ… App discovery and window enumeration - βœ… **AI vision analysis (8 comprehensive tests)** - One-step: Screenshot + AI analysis - Two-step: Analyze existing images - Model auto-detection and custom models - Error handling and edge cases - βœ… Enhanced error messaging - βœ… Performance and stress testing - βœ… Integration workflows - βœ… Compatibility with system apps **AI Test Details:** ```bash # Specific AI testing scenarios ./test_peekaboo.sh ai ``` - βœ… One-step screenshot + analysis workflow - βœ… Custom model specification testing - βœ… Two-step analysis of existing images - βœ… Complex questions with special characters - βœ… Invalid model error handling - βœ… Missing file error handling - βœ… Malformed command validation - βœ… Graceful Ollama/model availability checks --- ## βš™οΈ **CUSTOMIZATION** Tweak the magic in the script headers: ```applescript property captureDelay : 1.0 -- Wait before snap property windowActivationDelay : 0.5 -- Window focus time property enhancedErrorReporting : true -- Detailed errors property verboseLogging : false -- Debug output ``` --- ## πŸŽ‰ **WHY PEEKABOO ROCKS** ### πŸš€ **Unattended = Unstoppable** - No clicking, no selecting, no babysitting - Perfect for automation and CI/CD - Set it and forget it ### 🧠 **Smart Everything** - **Smart filenames**: Model-friendly with app names - **Smart targeting**: Works with app names OR bundle IDs - **Smart delays**: Optimized for speed (70% faster) - **Smart AI analysis**: Auto-detects best vision model - Auto-launches sleeping apps and brings them forward ### 🎭 **Multi-Window Mastery** - Captures ALL windows with descriptive names - Safe filename generation with sanitization - Never overwrites accidentally ### ⚑ **Blazing Fast** - **0.3s capture delay** (down from 1.0s) - **0.2s window activation** (down from 0.5s) - **0.1s multi-window focus** (down from 0.3s) - Responsive and practical for daily use ### πŸ€– **AI-Powered Vision** - **Local analysis**: Private Ollama integration, no cloud - **Smart model selection**: Auto-picks best available model - **One or two-step**: Screenshot+analyze or analyze existing images - **Perfect for automation**: Visual testing, error detection, QA ### πŸ” **Discovery Built-In** - See exactly what's running - Get precise window titles - No more guessing games --- ## πŸ“š **INSPIRED BY** Built in the style of the legendary **terminator.scpt** β€” because good patterns should be celebrated and extended. --- ## πŸŽͺ **PROJECT FILES** ``` πŸ“ Peekaboo/ β”œβ”€β”€ 🎯 peekaboo.scpt # Main screenshot tool β”œβ”€β”€ πŸ§ͺ test_screenshotter.sh # Test suite └── πŸ“– README.md # This awesomeness ``` --- ## πŸ† **THE BOTTOM LINE** **Peekaboo** doesn't just take screenshots. It **conquers** them. πŸ‘€ Point β†’ πŸ“Έ Shoot β†’ πŸ’Ύ Save β†’ πŸŽ‰ Done! *Now you see it, now it's saved. Peekaboo!* --- *Built with ❀️ and lots of β˜• for the macOS automation community.*