-
Notifications
You must be signed in to change notification settings - Fork 8
Home
TextGrabber2 does not take screenshots. Instead, you can use the system's built-in keyboard shortcuts to copy a portion of the screen to the clipboard and open TextGrabber2 to detect text.
By default, the keyboard shortcut for this action is Control-Shift-Command-4, as mentioned here (the last section).
However, pressing Control-Shift-Command-4 can be difficult, so it is recommended to remap it to a simpler combination. Please check out Apple's documentation for details.
I personally use Shift-Command-2, in case you're interested.
On macOS 15.4 and above, you may encounter system permission controls for clipboard access.
To ensure TextGrabber2 works properly, it's recommended to go to System Settings > Privacy & Security > Paste from Other Apps and set TextGrabber2's permission to Allow.
TextGrabber2 offers a way to use system services, you can easily integrate your workflows, this includes support for the Shortcuts app (similarly, it works with the Automator app too).
A service is defined as simplify just two properties (both are required, make sure all items are valid), for example:
{
"serviceName": "Search With %WebSearchProvider@",
"displayName": "Search in Safari"
}serviceName is the identifier to find the service, it is unique and often not human-readable.
displayName is simply what appears in TextGrabber2, can be any value you prefer. (Optional — if not specified, serviceName will be used instead.)
To find names for core services, open /System/Library/CoreServices/com.apple.NSServicesRestrictions.plist (need a plist editor, like Xcode) and search for NSServices and NSMenuItem.
Also, if an app offers services, open AppName.app/Contents/Info.plist and search for NSServices and NSMenuItem. For example, /System/Library/Services/Summary\ Service.app/Contents/Info.plist tells us its service name is Summarize.
Luckily, if the service is built using Shortcuts (or Automator), its serviceName will be exactly the Shortcut name. Here is an example of how we build a simple translate service using Shortcuts:
Make sure Services Menu is checked, and use Translate as the serviceName in our configuration file.
Note
After changing the services configuration, restart the app to apply your changes.
The output of the service will be copied back to the clipboard. It's recommended to only grab one sentence from the screen, if multiple sentences are recognized, the input will be concatenated with newlines.
When full clipboard access is granted to TextGrabber2, you can also define content filters to process the clipboard automatically.
Content filter rules are defined as a JSON array like this:
[
{
"type": "public.utf8-plain-text",
"match": "(https?:\\/\\/x\\.com\\/.*)\\?.*",
"runService": "Handle Links"
}
]This example includes a rule that detects the public.utf8-plain-text content type. When the content matches an x.com link (with parameters), it runs the service Handle Links (where you can remove the parameters from the link). When match is not provided, the service runs without performing any checks.
If you only want to replace a pattern, leverage match and replaceWith instead of runService, regex variables are available. For example, the above x.com sanitization can be implemented as:
[
{
"type": "public.utf8-plain-text",
"match": "(https?:\\/\\/x\\.com\\/.*)\\?.*",
"replaceWith": "$1"
}
]To exclude specific source applications, set the sourceApp parameter to the application name. For example, you can clear certain items only when the user copies content from PowerPoint.
You can use this feature to handle clipboard data automatically, such as purging sensitive data or normalizing content. Note that if a service modifies the clipboard content, make sure it does not result in an infinite loop.
Note
After changing the content filter rules, restart the app to apply your changes.
See Connect to System Services for the specification of a system service.
TextGrabber2 provides several handy Shortcuts actions for working with clipboard data more easily.
Content types are often Uniform Type Identifier if they are public (for example, you can use public.text to match both public.utf8-plain-text and public.html).
To include multiple values in type and sourceApp, use commas as separators, such as public.tiff, com.adobe.pdf.
You are welcomed to use my WhatCopied app to debug clipboard types.
TextGrabber2 offers a way to bind keyboard shortcuts to any action, including all built-in tools and added services.
To do this, edit the following file:
~/Library/Containers/app.cyan.textgrabber2/Data/Documents/key-bindings.json
Add key bindings following this specification:
[
{
"key": "T",
"modifiers": ["Option", "Command"],
"actionName": "Translate"
}
]Valid modifiers are Shift, Control, Option, and Command. See KeyCodes for valid key codes.
actionName is the menu item title shown in the app. It may vary depending on the locale. Use TextGrabber2 as a special name to open the app.
Note
All values are case-sensitive.
After changing the key binding rules, restart the app to apply your changes.
You can use the following defaults keys to customize certain behaviors of the app (bundle identifier: app.cyan.textgrabber2):
Disables app updates entirely.
Specifies an alternative status bar icon using an SF Symbol.
Sets the pasteboard polling interval, in seconds.
Tip
Check https://macos-defaults.com/ for a practical guide on using the defaults command.