diff --git a/README.md b/README.md index ddaa6f3..c7c89f8 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ -# πŸ‘€ PEEKABOO! πŸ“Έ +# Peekabooβ€”screenshot got you! Now you see it, now it's saved. ![Peekaboo Banner](assets/banner.png) -## 🎯 **Peekabooβ€”screenshot got you! Now you see it, now it's saved.** - πŸ‘€ β†’ πŸ“Έ β†’ πŸ’Ύ β€” **Unattended screenshot automation that actually works** --- @@ -21,31 +19,37 @@ --- -## πŸŽͺ **TWO FLAVORS** +## πŸŽͺ **HOW TO USE** -### 🎯 **Peekaboo Classic** (`peekaboo.scpt`) -*Simple. Fast. Reliable.* +### 🎯 **Basic Usage** +*Simple screenshot capture* ```bash -# πŸ‘€ One app, one shot +# πŸ‘€ Quick shot to /tmp with timestamp +osascript peekaboo.scpt "Safari" + +# 🎯 Custom output path osascript peekaboo.scpt "Safari" "/Users/you/Desktop/safari.png" # 🎯 Bundle ID targeting osascript peekaboo.scpt "com.apple.TextEdit" "/tmp/textedit.jpg" ``` -### πŸŽͺ **Peekaboo Pro** (`peekaboo_enhanced.scpt`) +### πŸŽͺ **Advanced Features** *All the power. All the windows. All the time.* ```bash # πŸ” What's running right now? -osascript peekaboo_enhanced.scpt list +osascript peekaboo.scpt list + +# πŸ‘€ Quick shot to /tmp with timestamp +osascript peekaboo.scpt "Chrome" # 🎭 Capture ALL windows with smart names -osascript peekaboo_enhanced.scpt "Chrome" "/tmp/chrome.png" --multi +osascript peekaboo.scpt "Chrome" "/tmp/chrome.png" --multi # πŸͺŸ Just the front window -osascript peekaboo_enhanced.scpt "TextEdit" "/tmp/textedit.png" --window +osascript peekaboo.scpt "TextEdit" "/tmp/textedit.png" --window ``` --- @@ -54,13 +58,20 @@ osascript peekaboo_enhanced.scpt "TextEdit" "/tmp/textedit.png" --window ### 🎯 **Basic Shot** ```bash +# Quick shot with auto-generated filename +osascript peekaboo.scpt "Finder" +``` +**Result**: Full screen with Finder in focus β†’ `/tmp/peekaboo_20250522_143052.png` + +```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_enhanced.scpt "Safari" "/tmp/safari.png" --multi +osascript peekaboo.scpt "Safari" "/tmp/safari.png" --multi ``` **Result**: Multiple files with smart names: - `safari_window_1_GitHub.png` @@ -69,7 +80,7 @@ osascript peekaboo_enhanced.scpt "Safari" "/tmp/safari.png" --multi ### πŸ” **App Discovery** ```bash -osascript peekaboo_enhanced.scpt list +osascript peekaboo.scpt list ``` **Result**: Every running app + window titles. No guessing! @@ -79,7 +90,7 @@ osascript peekaboo_enhanced.scpt list ### 1️⃣ **Make Executable** ```bash -chmod +x peekaboo.scpt peekaboo_enhanced.scpt +chmod +x peekaboo.scpt ``` ### 2️⃣ **Grant Powers** @@ -94,7 +105,10 @@ chmod +x peekaboo.scpt peekaboo_enhanced.scpt Peekaboo speaks all the languages: ```bash -# PNG (default) - crisp and clean +# PNG (default) - auto-generated in /tmp +osascript peekaboo.scpt "Safari" + +# PNG with custom path osascript peekaboo.scpt "Safari" "/tmp/shot.png" # JPG - smaller files @@ -110,7 +124,10 @@ osascript peekaboo.scpt "Safari" "/tmp/shot.pdf" ### 🎯 **Targeting Options** ```bash -# By name (easy) +# By name (easy) - auto path +osascript peekaboo.scpt "Safari" + +# By name with custom path osascript peekaboo.scpt "Safari" "/tmp/safari.png" # By bundle ID (precise) @@ -134,7 +151,7 @@ osascript peekaboo.scpt "Final Cut Pro" "/tmp/finalcut.png" ### πŸ” **Discovery Mode** ```bash -osascript peekaboo_enhanced.scpt list +osascript peekaboo.scpt list ``` Shows you: - πŸ“± All running apps @@ -148,15 +165,23 @@ Shows you: ### πŸ“Š **Documentation Screenshots** ```bash -# Capture your entire workflow -osascript peekaboo_enhanced.scpt "Xcode" "/docs/xcode.png" --multi -osascript peekaboo_enhanced.scpt "Terminal" "/docs/terminal.png" --multi -osascript peekaboo_enhanced.scpt "Safari" "/docs/browser.png" --multi +# 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 -# Automated testing screenshots +# Quick automated testing screenshots +osascript peekaboo.scpt "Your App" + +# Custom path with timestamp osascript peekaboo.scpt "Your App" "/test-results/app-$(date +%s).png" ``` @@ -179,7 +204,7 @@ osascript peekaboo.scpt "Photoshop" "/content/after.png" ### πŸ‘» **App Not Found?** ```bash # See what's actually running -osascript peekaboo_enhanced.scpt list +osascript peekaboo.scpt list # Try the bundle ID instead osascript peekaboo.scpt "com.company.AppName" "/tmp/shot.png" @@ -192,23 +217,24 @@ osascript peekaboo.scpt "com.company.AppName" "/tmp/shot.png" ### πŸ› **Debug Mode** ```bash -osascript peekaboo_enhanced.scpt "Safari" "/tmp/debug.png" --verbose +osascript peekaboo.scpt "Safari" "/tmp/debug.png" --verbose ``` --- -## πŸŽͺ **COMPARISON** +## πŸŽͺ **FEATURES** -| Feature | Classic 🎯 | Pro πŸŽͺ | -|---------|------------|--------| -| Basic screenshots | βœ… | βœ… | -| App targeting | βœ… | βœ… | -| Multi-format | βœ… | βœ… | -| **App discovery** | ❌ | βœ… | -| **Multi-window** | ❌ | βœ… | -| **Smart naming** | ❌ | βœ… | -| **Window modes** | ❌ | βœ… | -| **Verbose logging** | ❌ | βœ… | +| 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 /tmp default | +| **Verbose logging** | βœ… `--verbose` for debugging | --- @@ -280,9 +306,8 @@ Built in the style of the legendary **terminator.scpt** β€” because good pattern ## πŸŽͺ **PROJECT FILES** ``` -πŸ“ AppleScripts/ -β”œβ”€β”€ 🎯 peekaboo.scpt # Classic version -β”œβ”€β”€ πŸŽͺ peekaboo_enhanced.scpt # Pro version +πŸ“ Peekaboo/ +β”œβ”€β”€ 🎯 peekaboo.scpt # Main screenshot tool β”œβ”€β”€ πŸ§ͺ test_screenshotter.sh # Test suite └── πŸ“– README.md # This awesomeness ``` diff --git a/peekaboo.scpt b/peekaboo.scpt index 349f2c6..f8465c7 100755 --- a/peekaboo.scpt +++ b/peekaboo.scpt @@ -255,17 +255,24 @@ on run argv my logVerbose("Starting Screenshotter v1.0.0") set argCount to count argv - if argCount < 2 then return my usageText() + if argCount < 1 then return my usageText() set appIdentifier to item 1 of argv - set outputPath to item 2 of argv + + -- Use default tmp path if no output path provided + if argCount >= 2 then + set outputPath to item 2 of argv + else + set timestamp to do shell script "date +%Y%m%d_%H%M%S" + set outputPath to "/tmp/peekaboo_" & timestamp & ".png" + end if -- Validate arguments if appIdentifier is "" then return my formatErrorMessage("Argument Error", "App identifier cannot be empty." & linefeed & linefeed & my usageText(), "validation") end if - if not my isValidPath(outputPath) then + if argCount >= 2 and not my isValidPath(outputPath) then return my formatErrorMessage("Argument Error", "Output path must be an absolute path starting with '/'." & linefeed & linefeed & my usageText(), "validation") end if @@ -326,14 +333,17 @@ on usageText() set outText to outText & "Takes unattended screenshots of applications by name or bundle ID." & LF & LF set outText to outText & "Usage:" & LF - set outText to outText & " osascript " & scriptName & " \"\" \"\"" & LF & LF + set outText to outText & " osascript " & scriptName & " \"\" [\"\"]" & LF & LF set outText to outText & "Parameters:" & LF set outText to outText & " app_name_or_bundle_id: Application name (e.g., 'Safari') or bundle ID (e.g., 'com.apple.Safari')" & LF - set outText to outText & " output_path: Absolute path for screenshot file (e.g., '/Users/name/Desktop/screenshot.png')" & LF & LF + set outText to outText & " output_path: Optional absolute path for screenshot file" & LF + set outText to outText & " If not provided, saves to /tmp/peekaboo_TIMESTAMP.png" & LF & LF set outText to outText & "Examples:" & LF - set outText to outText & " # Screenshot Safari using app name:" & LF + set outText to outText & " # Screenshot Safari to /tmp with timestamp:" & LF + set outText to outText & " osascript " & scriptName & " \"Safari\"" & LF + set outText to outText & " # Screenshot Safari with custom path:" & LF set outText to outText & " osascript " & scriptName & " \"Safari\" \"/Users/username/Desktop/safari_shot.png\"" & LF set outText to outText & " # Screenshot using bundle ID:" & LF set outText to outText & " osascript " & scriptName & " \"com.apple.TextEdit\" \"/tmp/textedit.png\"" & LF diff --git a/peekaboo_enhanced.scpt b/peekaboo_enhanced.scpt index 8687aff..84153c9 100755 --- a/peekaboo_enhanced.scpt +++ b/peekaboo_enhanced.scpt @@ -497,10 +497,17 @@ on run argv end if end if - if argCount < 2 then return my usageText() + if argCount < 1 then return my usageText() set appIdentifier to item 1 of argv - set outputPath to item 2 of argv + + -- Use default tmp path if no output path provided + if argCount >= 2 then + set outputPath to item 2 of argv + else + set timestamp to do shell script "date +%Y%m%d_%H%M%S" + set outputPath to "/tmp/peekaboo_" & timestamp & ".png" + end if set captureMode to "screen" -- default set multiWindow to false @@ -524,7 +531,7 @@ on run argv return my formatErrorMessage("Argument Error", "App identifier cannot be empty." & linefeed & linefeed & my usageText(), "validation") end if - if not my isValidPath(outputPath) then + if argCount >= 2 and not my isValidPath(outputPath) then return my formatErrorMessage("Argument Error", "Output path must be an absolute path starting with '/'." & linefeed & linefeed & my usageText(), "validation") end if @@ -624,13 +631,14 @@ on usageText() set outText to outText & "Takes unattended screenshots with multi-window support and app discovery." & LF & LF set outText to outText & "Usage:" & LF - set outText to outText & " osascript " & scriptName & " \"\" \"\" [options]" & LF + set outText to outText & " osascript " & scriptName & " \"\" [\"\"] [options]" & LF set outText to outText & " osascript " & scriptName & " list" & LF set outText to outText & " osascript " & scriptName & " help" & LF & LF set outText to outText & "Parameters:" & LF set outText to outText & " app_name_or_bundle_id: Application name (e.g., 'Safari') or bundle ID (e.g., 'com.apple.Safari')" & LF - set outText to outText & " output_path: Absolute path for screenshot file(s)" & LF & LF + set outText to outText & " output_path: Optional absolute path for screenshot file(s)" & LF + set outText to outText & " If not provided, saves to /tmp/peekaboo_TIMESTAMP.png" & LF & LF set outText to outText & "Options:" & LF set outText to outText & " --window, -w: Capture frontmost window only" & LF @@ -645,14 +653,14 @@ on usageText() set outText to outText & "Examples:" & LF set outText to outText & " # List running applications:" & LF set outText to outText & " osascript " & scriptName & " list" & LF - set outText to outText & " # Full screen capture:" & LF + set outText to outText & " # Screenshot Safari to /tmp with timestamp:" & LF + set outText to outText & " osascript " & scriptName & " \"Safari\"" & LF + set outText to outText & " # Full screen capture with custom path:" & LF set outText to outText & " osascript " & scriptName & " \"Safari\" \"/Users/username/Desktop/safari.png\"" & LF set outText to outText & " # Front window only:" & LF set outText to outText & " osascript " & scriptName & " \"TextEdit\" \"/tmp/textedit.png\" --window" & LF set outText to outText & " # All windows with descriptive names:" & LF - set outText to outText & " osascript " & scriptName & " \"Safari\" \"/tmp/safari_windows.png\" --multi" & LF - set outText to outText & " # Interactive selection:" & LF - set outText to outText & " osascript " & scriptName & " \"Finder\" \"/tmp/finder.png\" --interactive" & LF & LF + set outText to outText & " osascript " & scriptName & " \"Safari\" \"/tmp/safari_windows.png\" --multi" & LF & LF set outText to outText & "Multi-Window Features:" & LF set outText to outText & " β€’ --multi creates separate files with descriptive names" & LF