-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: master
Are you sure you want to change the base?
Pr 78 #86
Conversation
- Add OSX and LINUX compilation symbols to cycod.csproj - Implement native macOS screenshot capture using Core Graphics framework - Add P/Invoke declarations for CGDisplay, CoreFoundation, and ImageIO APIs - Update platform support checks to include macOS alongside Windows - Update error messages and descriptions to reflect macOS support - Maintain proper memory management with CFRelease for Core Foundation objects The implementation uses native macOS APIs without external dependencies: - CGDisplayCreateImage for screen capture - CGImageDestination for PNG export - CFURL and CFString for file path handling Tested: Build succeeds with no errors or warnings
Features: - ListWindows() - Enumerate all visible application windows with metadata (JSON) - TakeScreenshotOfApp(appName) - Capture screenshots by application name - TakeScreenshotOfWindowWithTitle(title) - Capture screenshots by window title - TakeScreenshotOfDisplay(displayNumber) - Capture specific displays - TakeScreenshotOfWindow(windowId) - Advanced: capture by window ID Implementation: - Uses hybrid approach: Core Graphics for window enumeration + screencapture CLI for capture - No Screen Recording permissions required when run from terminal - Case-insensitive, partial matching for app names and titles - Returns helpful error messages when multiple windows match - Properly guarded with #if OSX for macOS-only code Files: - Added: src/cycod/Helpers/WindowInfo.cs - Window metadata class - Modified: src/cycod/Helpers/ScreenshotHelper.cs - Core screenshot and enumeration logic - Modified: src/cycod/FunctionCallingTools/ScreenshotHelperFunctions.cs - AI tool wrappers - Added: docs/macos-window-screenshot-feature.md - Feature documentation Fixes: - Fixed macOS screenshot permissions issue by using screencapture CLI instead of Core Graphics capture - Fixed CGWindowListCopyWindowInfo import (CoreGraphics framework, not CoreFoundation) - Fixed dictionary key names (use 'k' prefix: kCGWindowOwnerName)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR extends cycod's screenshot functionality to support macOS in addition to Windows. On Windows, it captures the default screen; on macOS, it can capture specific windows identified by name or process ID, as well as entire displays.
Key Changes:
- Added macOS screenshot support using native
screencaptureutility and Core Graphics APIs - Implemented window enumeration and targeted screenshot capture for macOS
- Updated platform checks throughout to include OSX alongside Windows
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/cycod/cycod.csproj | Added OSX and LINUX build constants for conditional compilation |
| src/cycod/SlashCommands/SlashScreenshotCommandHandler.cs | Updated platform check to support both Windows and macOS |
| src/cycod/Helpers/WindowInfo.cs | New data class representing macOS window metadata |
| src/cycod/Helpers/ScreenshotHelper.cs | Core screenshot functionality with macOS window enumeration and capture methods |
| src/cycod/FunctionCallingTools/ScreenshotHelperFunctions.cs | AI-callable wrapper functions for screenshot operations |
| docs/macos-window-screenshot-feature.md | Documentation of the new macOS screenshot capabilities |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR adds the ability for cycod to take screenshots, both on Window and on MacOS.
On Windows it will take a screenshot of the default screen.
On MacOS it can take a screenshot of any window that can be identified by name or process id.