This is a macOS library that allows you to easily get the selected text.
It's a part of Easydict.
- Get selected text via AXUI
- Get selected text by menu bar action copy
- Get selected text by shortcut key
cmd + c
import SelectedTextKit
// Get selected text via AXUI, if fails, it will try to get text by menu bar action copy.
let text = try await getSelectedText()
// Get selected text by menu bar action copy
let text = try await getSelectedTextByMenuBarActionCopy()
Get selected text by menu bar action copy is inspired by Copi, thanks for s1ntoneli's work.