Screenshot OCR with BetterTouchTool on MacOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Usage: | |
# - Install `tesseract` with `brew install tesseract` | |
# - In BetterTouchTool, create a trigger of your choice. | |
# (I recommend a Keyboard Shortcut with Cmd+Shift 6) | |
# - Add an Execute Shell Script / Task action | |
# - Paste this script. | |
# NOTE: You'll need to authorize BTT to the Screen Recording permission in Security and Privacy at System Preferences | |
# When using this quick script, it'll use MacOS' screencapture tool, use tesseract for OCR and then pass the scanned | |
# text to your clipboard using pbcopy. | |
screencapture -i /tmp/tesseract.png && /opt/homebrew/bin/tesseract --dpi 72 /tmp/tesseract.png stdout | tr -d \\f | pbcopy | |
PREVIEW=`pbpaste | head -n 3` | |
# A one liner snippet is also provided via a notification. | |
osascript -e "display notification \"${PREVIEW}...\" with title \"OCR captured to clipboard.\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Intel Mac make sure to change location of Tessract -
/opt/homebrew/bin/tesseract
- in the script example above, to/usr/local/bin/tesseract
You can make sure you have correct location by typingwhich tesseract
in the Terminal and it will spit out the current install location on your computer for you , which you can then copy and paste and use to put in the script above. Should work great!