Skip to content

Add global OCR text capture (Ctrl/Cmd+Shift+T) - #2095

Closed
x1xhlol wants to merge 1 commit into
CapSoftware:mainfrom
x1xhlol:feat/ocr-text-capture
Closed

x1xhlol wants to merge 1 commit into
CapSoftware:mainfrom
x1xhlol:feat/ocr-text-capture

Conversation

@x1xhlol

@x1xhlol x1xhlol commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a privacy-first "copy text from screen" feature: press Ctrl+Shift+T (Windows) / Cmd+Shift+T (macOS), drag over any screen region with the existing area selector, and the recognized text is copied straight to the clipboard. Nothing is written to disk by default.

Reuses Cap's existing native OCR engines (Apple Vision on macOS, Windows.Media.Ocr on Windows) — no new dependency, free, fast, on-device.

How it fits together:

  • HotkeyAction::OcrArea — new hotkey action, seeded with a default binding on startup via seed_default_hotkeys (a seeded list in HotkeysStore ensures it's only auto-added once and never overrides a user's existing binding). Pressing it opens the target-select overlay in a new RecordingTargetMode::Ocr.
  • target-select-overlay.tsx — "ocr" target mode reuses the area-selector UI (screenshot-style: 1×1 min size, no recording controls, toolbar hint "Draw an area to copy text"). On mouse-up it invokes the new command instead of takeScreenshot; on error the overlay is restored with a toast.
  • capture_ocr_text (recording.rs) — new Tauri command:
    capture region in-memory → recognize_text_from_dynamic_image (native OCR)
      → clipboard.write_text → optional save_screenshot_project → optional notification
    
  • take_screenshot was split into capture_screen_image + save_screenshot_project so OCR shares the capture/persistence code without duplicating it.
  • Settings:
    • General → new "Text capture (OCR)" section with two default-off toggles: ocr_keep_screenshot (save the region as a normal screenshot project) and ocr_show_notification (system notification with a preview of the copied text).
    • Shortcuts → "Copy text from area (OCR)" entry, rebindable like any other hotkey.

Showcase

Pressing the shortcut opens the familiar area selector, in text-capture mode:

OCR capture overlay

Drag over any text and it lands on the clipboard (nothing written to disk):

OCR text copied to clipboard

The capture is a background gesture — the app you were in keeps keyboard focus afterwards:

Focus stays on the previous app

Settings — rebindable shortcut and the two default-off toggles:

Shortcut entry

Text capture settings

Testing (Windows, end-to-end on a live dev build)

Test Result
Ctrl+Shift+T opens OCR overlay ("Draw an area to copy text") ✅
Drag region → OCR text copied to clipboard (exact match) ✅
No screenshot persisted by default ✅
Shortcuts: "Copy text from area (OCR)" = Ctrl Shift T ✅
General: "Text capture (OCR)" toggles present, default OFF ✅
"Keep a screenshot" ON → .cap screenshot project created ✅

Known minor limitation: a very thin selection (~30 px tall) can return "No text was found in the selected area" (Windows.Media.Ocr small-region behavior); handled gracefully with a toast, slightly larger selections work.

macOS path uses the same Vision-based OCR code Cap already ships for the screenshot editor; it compiles for both platforms but was runtime-tested on Windows only.

RetriggerConfidence Score: 5/5

The PR appears safe to merge.

Summary

The PR adds global area-based OCR capture using the existing native OCR engines and copies recognized text directly to the clipboard.

  • Adds a configurable global OCR hotkey and OCR target-selection mode.
  • Adds optional screenshot persistence and text-preview notifications.
  • Refactors screenshot capture so OCR can reuse in-memory capture while restoring temporarily hidden overlays.
  • Adds settings and target-selector UI for the new workflow.

Reviews (3) · Last reviewed commit: "Add global OCR text capture (Ctrl/Cmd+Sh..." · Reviewed by Greptile

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks for this. The branch now conflicts with main (recording.rs, hotkeys.rs, tauri.ts). Could you rebase, regenerate the tauri bindings, and re-trigger Greptile? We need Greptile at 5/5 on the latest commit and green CI before we review.

@x1xhlol

x1xhlol commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P1 Capture leaves overlays hidden apps/desktop/src-tauri/src/recording.rs:2878 ▶

    When OCR runs while another Cap overlay is visible, capture_screen_image hides that window without restoring its visibility or cursor-event state, causing recordings, mode-selection, capture-area, or occluder overlays to remain inaccessible after the capture succeeds or fails.

@x1xhlol

x1xhlol commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai review

@x1xhlol

x1xhlol commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Hey, 5/5 now

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks so much for this contribution, @x1xhlol! Cap's desktop app has now fully moved from Tauri to our new native GPUI app (apps/desktop-gpui), which ships as Cap from 0.6.1 on macOS, Windows and Linux. This PR only changes the old Tauri app (apps/desktop), so it no longer affects what we ship, and I'm closing it. If the change still makes sense for the GPUI app, we'd love a PR against apps/desktop-gpui. Really appreciate the time you put into this.

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.

2 participants