Skip to content

Conversation

@robch
Copy link
Owner

@robch robch commented Jan 11, 2026

This PR adds automatic screenshot resizing to keep file sizes manageable and makes minor UI improvements to speech input.

Changes:

  • Add ResizeImageIfNeeded() method to ScreenshotHelper
  • Automatically resize screenshots to max 1200px dimension (maintains aspect ratio)
  • Supports Windows (System.Drawing) and macOS (sips command)
  • Remove extra newline from speech input prompt
  • Change recognized speech text display from yellow to white for better consistency

Testing:

  • Screenshot resizing works on both Windows and macOS
  • Images under 1200px are left unchanged
  • Speech input UI displays correctly

robch and others added 8 commits December 12, 2025 11:10
- 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)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@robch robch marked this pull request as draft January 11, 2026 23:59
@robch robch marked this pull request as ready for review January 14, 2026 09:22
@robch robch merged commit 666d5df into master Jan 14, 2026
1 check passed
@robch robch deleted the robch/2601-jan11-screenshot-resize-speech-ui branch January 14, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants