A macOS command line tool for finding, OCRing, and raising windows.
macwin enumerates application windows, filters them by title or predicate, optionally runs OCR on window-local rectangles, and can raise or close matching windows. It is packaged as MacWin.app so macOS privacy permissions are granted to the app bundle rather than to every caller application.
Install from my Homebrew tap:
% brew install knu/knu/macwinOr tap it first:
% brew tap knu/knu
% brew install macwinThe Homebrew formula builds MacWin.app from source and installs the macwin-cli wrapper.
To build from a checkout instead:
% make install-appThis installs MacWin.app to ~/Applications. Use the local wrapper script to launch the app-backed CLI:
% bin/macwin-cli --help% macwin find (--app NAME | --bundle-id ID | --window-id ID) [OPTIONS]
% macwin raise --window-id ID
% macwin close --window-id IDFind Edge windows:
% bin/macwin-cli find --bundle-id com.microsoft.Edge --prettyFilter by title and stop after the first match:
% bin/macwin-cli find --app "Microsoft Edge" --title-regex Dashboard --limit 1 --prettyRaise a specific window:
% bin/macwin-cli raise --window-id 12345Close a specific window:
% bin/macwin-cli close --window-id 12345Find and raise matching windows:
% bin/macwin-cli find --bundle-id com.microsoft.Edge --title-regex Dashboard --raise --exit-statusUse --ocr to recognize text from one or more window-local rectangles:
% bin/macwin-cli find --bundle-id com.microsoft.Edge \
--ocr '0,0,400,120;name=header' \
--where 'ANY ocr.text MATCHES ".*Dashboard.*"' \
--prettyOCR rectangles use logical coordinates with the origin at the window's top-left corner.
- Negative
XandYare relative to the right and bottom edge. WorHof0means the remaining width or height.- Negative
WorHmeans the remaining width or height minus that many points. ;name=NAMEtags OCR tokens from that rectangle.;save_image=PATHwrites the cropped image for inspection.
--app NAME— Match application name.--bundle-id ID— Match bundle identifier.--window-id ID— Match a specific CG window ID.--title-regex REGEX— Match the window title.--ocr X,Y,W,H[;name=NAME][;save_image=PATH]— OCR a window-local rectangle. Repeatable.--where NSPREDICATE— Filter with anNSPredicate. Repeatable; predicates are ANDed.--lang ja,en— OCR recognition languages.--min-confidence VALUE— Discard OCR tokens below the confidence value.--limit COUNT— Stop after finding this many windows.--wait SEC— Retry up toSECseconds until the filter conditions match. Requires at least one of--title-regex,--where, or--limit. Polls every 0.5s (1.0s when--ocris used).--exit-status— Exit with status 1 if no windows matched.--raise— Raise matched windows.--include-offscreen— Include offscreen windows.--ax— Includeax_titlein JSON output.--pretty— Pretty-print JSON.
The title field prefers CGWindowName and falls back to SCWindow.title when needed.
find writes JSON to stdout:
{
"windows": [
{
"window_id": 12345,
"pid": 678,
"app_name": "Microsoft Edge",
"bundle_id": "com.microsoft.Edge",
"title": "Home - Microsoft Edge",
"bounds": { "x": 0, "y": 25, "w": 1440, "h": 900 }
}
]
}With OCR:
{
"windows": [
{
"window_id": 12345,
"ocr": [
{
"name": "header",
"text": "Home Dashboard",
"confidence": 0.98,
"bbox": { "x": 40, "y": 8, "w": 160, "h": 20 }
}
]
}
]
}- Screen Recording — Required for OCR and
SCWindow.titlefallback. - Accessibility — Required for
raise,close, and--ax.
Copyright (c) 2026 Akinori Musha.
Licensed under the MIT license. See LICENSE for details.
Visit the GitHub Repository for the latest information.