TextGrabber2

repository·main·Indexed 42 days ago

https://github.com/textgrabber2-app/textgrabber2

An open-source macOS utility that extracts text from clipboard images using the Apple Vision framework and triggers system actions via Apple Shortcuts. It features a status bar menu for clipboard tools, content filters, and automation workflows without requiring Screen Recording or Accessibility permissions.

Tokens
1.1K
Snippets
1
Records
6
Agent score
4%

What's inside TextGrabber2

  1. Overview of TextGrabber2 features

    main

    TextGrabber2 is an open-source "Copy-to-Action" tool for macOS designed to automate workflows using clipboard data. Key capabilities include:

    • Text Extraction: Extract text from images currently in your clipboard.
    • Action Automation: Trigger Apple Shortcuts and other system services based on extracted text.
    • Clipboard Management: Automatically prune clipboard data using custom rules or services.
    • Built-in Tools: Access quick tools like Translate and Quick Look.
    • Key Bindings: Use custom key bindings to trigger common actions faster.
  2. How TextGrabber2 works

    main
    TextGrabber2 operates as a privacy-oriented clipboard observer. Unlike screenshot tools, it does not require Screen Recording or Accessibility permissions. Instead, it uses the on-device Apple Vision framework to process images and integrates with macOS system services via Shortcuts to execute workflows.
  3. Install TextGrabber2 on macOS

    main

    To install TextGrabber2, download the TextGrabber2.dmg file from the latest release. Open the disk image and drag TextGrabber2.app into your Applications folder.

    Note:

    • TextGrabber2 checks for updates automatically.
    • If you are on an older macOS version, specific builds are available for macos-13 and macos-14 in the releases section.
  4. Understand the TextGrabber2 App lifecycle and structure

    main

    The App class is the central coordinator for TextGrabber2, implementing NSApplicationDelegate. It manages the application's lifecycle, the system status bar item, and the main menu.

    Key responsibilities include:

    • Status Bar Management: Controls the statusItem which provides the entry point in the macOS menu bar.
    • Menu Construction: Dynamically builds a mainMenu containing various tools like clipboardToolsItem, servicesItem, and launchAtLoginItem.
    • Event Monitoring: Handles keyboard events and pasteboard changes via addEventMonitors() and updateObserver(isEnabled:).
    • Lifecycle Hooks: Uses applicationDidFinishLaunching to set the activation policy to .accessory (to run as a background/menu bar app), initialize services, and start update checks.
  5. Configure TextGrabber2 via the Status Bar Menu

    main

    The application provides several functional areas through its status bar menu:

    Clipboard Tools

    Accessible via clipboardToolsItem, these allow you to manipulate captured text:

    • Translate: Uses LookUp.showPopover for single words or Translator.showPopover for full text.
    • Quick Look: Previews the currently captured content.
    • Save As File: Saves the current clipboard content to a file.
    • Clipboard Inspector: Opens the macOS Clipboard Inspector.
    • Copy All: Provides options to join text with line breaks, spaces, or directly.
    • Clear Contents: Clears the current clipboard.
    • Observe Changes: (Requires full pasteboard access) Toggles automatic detection of clipboard changes.
    • Content Filters: Opens settings for text filtering.

    Services

    Accessible via servicesItem, this manages connections to system services and application settings.

    System Settings

    • Launch at Login: Toggles whether TextGrabber2 starts automatically when you log in using SMAppService.mainApp.toggle().
    • App Version: Displays the current version and provides a link to releases.
  6. Reference: App Configuration Keys

    main

    The App.Keys enum defines the UserDefaults keys used for application configuration and state tracking:

    KeyDescription
    general.disable-updatesDisables automatic update checks
    general.status-bar-iconThe symbol name for the status bar icon
    general.user-click-countTracks user interactions for analytics
    pasteboard.observe-changesToggles automatic clipboard monitoring
    pasteboard.observe-intervalThe interval for pasteboard observation
    app.textgrabber2.app-versionAction key for the app version menu item
    enum Keys {
        static let disableUpdates = "general.disable-updates"
        static let statusBarIcon = "general.status-bar-icon"
        static let userClickCount = "general.user-click-count"
        static let observeChanges = "pasteboard.observe-changes"
        static let observeInterval = "pasteboard.observe-interval"
        static let appVersionAction = "app.textgrabber2.app-version"
    }