-
Notifications
You must be signed in to change notification settings - Fork 5
Pr 78 #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mercersoft
wants to merge
6
commits into
master
Choose a base branch
from
pr-78
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Pr 78 #86
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f52a692
Add native macOS screenshot support using Core Graphics
robch c9d31ce
Add chat history for macOS screenshot implementation discussion
robch f1a28d3
Merge branch 'master' into robch/2512-dec12-macos-screenshot
robch 930e1e8
Add macOS window-specific screenshot functionality
mercersoft 6b65991
Update src/cycod/FunctionCallingTools/ScreenshotHelperFunctions.cs
mercersoft 678ddec
Update src/cycod/Helpers/ScreenshotHelper.cs
mercersoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # macOS Window-Specific Screenshot Feature | ||
|
|
||
| ## Summary | ||
|
|
||
| Added the ability to capture screenshots of specific windows and applications on macOS, in addition to the existing full-screen capture functionality. | ||
|
|
||
| ## New Features | ||
|
|
||
| ### For LLM/AI Tools: | ||
|
|
||
| 1. **TakeScreenshotOfWindowWithTitle(title)** - Capture window by title (partial match) | ||
| - Example: `TakeScreenshotOfWindowWithTitle("cycod")` | ||
| - Returns screenshot or helpful error if multiple matches | ||
|
|
||
| 2. **TakeScreenshotOfApp(appName)** - Capture window by application name | ||
| - Example: `TakeScreenshotOfApp("Warp")` | ||
| - Returns screenshot or helpful error if multiple matches | ||
|
|
||
| 3. **TakeScreenshotOfDisplay(displayNumber)** - Capture specific display | ||
| - Example: `TakeScreenshotOfDisplay(2)` for secondary monitor | ||
|
|
||
| 4. **ListWindows()** - Enumerate all visible windows | ||
| - Returns JSON array with window metadata | ||
| - Useful for exploration before capturing | ||
|
|
||
| 5. **TakeScreenshotOfWindow(windowId)** - Advanced: capture by window ID | ||
| - Requires calling ListWindows() first to get IDs | ||
|
|
||
| ### Implementation Details: | ||
|
|
||
| - **Platform**: macOS only (guarded with `#if OSX`) | ||
| - **Method**: Hybrid approach: | ||
| - Uses Core Graphics `CGWindowListCopyWindowInfo` for window enumeration (no permissions required) | ||
| - Uses `screencapture -l <windowid>` for actual capture (no permissions required) | ||
| - **Matching**: Case-insensitive, partial matching for app names and titles | ||
| - **Filtering**: Only shows normal application windows (layer 0) with titles | ||
| - **Error Handling**: Returns helpful messages when multiple windows match | ||
|
|
||
| ## Files Modified: | ||
|
|
||
| 1. **src/cycod/Helpers/WindowInfo.cs** (NEW) | ||
| - Data class for window metadata | ||
| - Contains: WindowId, ProcessId, ApplicationName, WindowTitle, Bounds, etc. | ||
|
|
||
| 2. **src/cycod/Helpers/ScreenshotHelper.cs** (MODIFIED) | ||
| - Added window enumeration methods | ||
| - Added new screenshot capture methods | ||
| - Added Core Foundation P/Invoke for window APIs | ||
|
|
||
| 3. **src/cycod/FunctionCallingTools/ScreenshotHelperFunctions.cs** (MODIFIED) | ||
| - Added AI tool wrappers for new methods | ||
| - Returns screenshots as DataContent or error messages | ||
| - Returns window list as JSON string | ||
|
|
||
| ## Usage Examples (from LLM perspective): | ||
|
|
||
| ``` | ||
| User: "Take a screenshot of my Warp terminal" | ||
| AI: TakeScreenshotOfApp("Warp") | ||
|
|
||
| User: "Take a screenshot of the window with 'cycod' in the title" | ||
| AI: TakeScreenshotOfWindowWithTitle("cycod") | ||
|
|
||
| User: "What windows are open?" | ||
| AI: ListWindows() | ||
|
|
||
| User: "Take a screenshot of my second monitor" | ||
| AI: TakeScreenshotOfDisplay(2) | ||
| ``` | ||
|
|
||
| ## Benefits: | ||
|
|
||
| - ✅ No Screen Recording permissions required | ||
| - ✅ LLM can target specific windows easily | ||
| - ✅ Simple one-call operations for common use cases | ||
| - ✅ Advanced APIs available for power users | ||
| - ✅ Helpful error messages when multiple matches exist | ||
| - ✅ Clean, maintainable code with proper platform guards | ||
|
|
||
| ## Testing: | ||
|
|
||
| Build succeeded with 0 warnings, 0 errors. | ||
|
|
||
| To test manually: | ||
| 1. Run: `./src/cycod/bin/Debug/net9.0/cycod chat` | ||
| 2. Ask the AI to list windows: "List all windows" | ||
| 3. Ask the AI to screenshot specific app: "Take a screenshot of Warp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.