mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-03-25 09:25:47 +00:00
⚡ Smart Filenames + Speed: Model-friendly names & 70% faster capture
Performance & UX improvements: • Smart filename generation with app names - /tmp/peekaboo_safari_20250522_143052.png (includes app) - Model-friendly: lowercase, underscores, no spaces - Multi-window: safari_window_1_github.png • Significantly reduced delays for speed - Capture delay: 1.0s → 0.3s (70% faster) - Window activation: 0.5s → 0.2s (60% faster) - Multi-window focus: 0.3s → 0.1s (67% faster) • Updated documentation with new filename examples • App names limited to 20 chars for readability Perfect for automation and model usage\! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4c1c255b7c
commit
327df522e1
3 changed files with 39 additions and 11 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
|
|
@ -61,7 +61,7 @@ osascript peekaboo.scpt "TextEdit" "/tmp/textedit.png" --window
|
|||
# Quick shot with auto-generated filename
|
||||
osascript peekaboo.scpt "Finder"
|
||||
```
|
||||
**Result**: Full screen with Finder in focus → `/tmp/peekaboo_20250522_143052.png`
|
||||
**Result**: Full screen with Finder in focus → `/tmp/peekaboo_finder_20250522_143052.png`
|
||||
|
||||
```bash
|
||||
# Custom path
|
||||
|
|
@ -74,9 +74,9 @@ osascript peekaboo.scpt "Finder" "/Desktop/finder.png"
|
|||
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`
|
||||
- `safari_window_1_github.png`
|
||||
- `safari_window_2_documentation.png`
|
||||
- `safari_window_3_google_search.png`
|
||||
|
||||
### 🔍 **App Discovery**
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
--#region Configuration Properties
|
||||
property scriptInfoPrefix : "Peekaboo 👀: "
|
||||
property defaultScreenshotFormat : "png"
|
||||
property captureDelay : 1.0
|
||||
property windowActivationDelay : 0.5
|
||||
property captureDelay : 0.3
|
||||
property windowActivationDelay : 0.2
|
||||
property enhancedErrorReporting : true
|
||||
property verboseLogging : false
|
||||
property maxWindowTitleLength : 50
|
||||
|
|
@ -60,6 +60,32 @@ on sanitizeFilename(filename)
|
|||
return filename
|
||||
end sanitizeFilename
|
||||
|
||||
on sanitizeAppName(appName)
|
||||
-- Create model-friendly app names (lowercase, underscores, no spaces)
|
||||
set appName to my replaceText(appName, " ", "_")
|
||||
set appName to my replaceText(appName, ".", "_")
|
||||
set appName to my replaceText(appName, "-", "_")
|
||||
set appName to my replaceText(appName, "/", "_")
|
||||
set appName to my replaceText(appName, ":", "_")
|
||||
set appName to my replaceText(appName, "*", "_")
|
||||
set appName to my replaceText(appName, "?", "_")
|
||||
set appName to my replaceText(appName, "\"", "_")
|
||||
set appName to my replaceText(appName, "<", "_")
|
||||
set appName to my replaceText(appName, ">", "_")
|
||||
set appName to my replaceText(appName, "|", "_")
|
||||
-- Convert to lowercase using shell
|
||||
try
|
||||
set appName to do shell script "echo " & quoted form of appName & " | tr '[:upper:]' '[:lower:]'"
|
||||
on error
|
||||
-- Fallback if shell command fails
|
||||
end try
|
||||
-- Limit length for readability
|
||||
if (length of appName) > 20 then
|
||||
set appName to text 1 thru 20 of appName
|
||||
end if
|
||||
return appName
|
||||
end sanitizeAppName
|
||||
|
||||
on replaceText(theText, searchStr, replaceStr)
|
||||
set oldDelims to AppleScript's text item delimiters
|
||||
set AppleScript's text item delimiters to searchStr
|
||||
|
|
@ -444,7 +470,7 @@ on captureMultipleWindows(appName, baseOutputPath)
|
|||
repeat with winInfo in windowInfo
|
||||
set winTitle to item 1 of winInfo
|
||||
set winIndex to item 2 of winInfo
|
||||
set sanitizedTitle to my sanitizeFilename(winTitle)
|
||||
set sanitizedTitle to my sanitizeAppName(winTitle)
|
||||
|
||||
set windowFileName to baseNameNoExt & "_window_" & winIndex & "_" & sanitizedTitle & "." & fileExt
|
||||
set windowOutputPath to outputDir & "/" & windowFileName
|
||||
|
|
@ -459,7 +485,7 @@ on captureMultipleWindows(appName, baseOutputPath)
|
|||
end tell
|
||||
end tell
|
||||
end tell
|
||||
delay 0.3
|
||||
delay 0.1
|
||||
on error
|
||||
my logVerbose("Could not focus window " & winIndex & ", continuing anyway")
|
||||
end try
|
||||
|
|
@ -506,7 +532,9 @@ on run argv
|
|||
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"
|
||||
-- Create model-friendly filename with app name
|
||||
set appNameForFile to my sanitizeAppName(appIdentifier)
|
||||
set outputPath to "/tmp/peekaboo_" & appNameForFile & "_" & timestamp & ".png"
|
||||
end if
|
||||
set captureMode to "screen" -- default
|
||||
set multiWindow to false
|
||||
|
|
@ -638,7 +666,7 @@ on usageText()
|
|||
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: 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 & " If not provided, saves to /tmp/peekaboo_appname_TIMESTAMP.png" & LF & LF
|
||||
|
||||
set outText to outText & "Options:" & LF
|
||||
set outText to outText & " --window, -w: Capture frontmost window only" & LF
|
||||
|
|
@ -672,7 +700,7 @@ on usageText()
|
|||
set outText to outText & " • Requires Screen Recording permission in System Preferences" & LF
|
||||
set outText to outText & " • Accessibility permission may be needed for window enumeration" & LF
|
||||
set outText to outText & " • Window titles longer than " & maxWindowTitleLength & " characters are truncated" & LF
|
||||
set outText to outText & " • Default capture delay: " & (captureDelay as string) & " second(s)" & LF
|
||||
set outText to outText & " • Default capture delay: " & (captureDelay as string) & " second(s) (optimized for speed)" & LF
|
||||
|
||||
return outText
|
||||
end usageText
|
||||
|
|
|
|||
Loading…
Reference in a new issue