Add Kapture: menu-bar screenshot OCR app with Cmd+Shift+S hotkey

This commit is contained in:
2026-08-09 18:15:21 +08:00
commit e814e63c0f
11 changed files with 655 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import Carbon
import AppKit
final class HotkeyManager {
static let shared = HotkeyManager()
var onTrigger: (() -> Void)?
private var hotKeyRef: EventHotKeyRef?
private var eventHandlerRef: EventHandlerRef?
private var hotKeyID = EventHotKeyID(signature: 0x4B505452, id: 1)
private init() {}
func register() {
var eventType = EventTypeSpec(
eventClass: OSType(kEventClassKeyboard),
eventKind: UInt32(kEventHotKeyPressed)
)
InstallEventHandler(GetApplicationEventTarget(), { _, _, _ in
HotkeyManager.shared.onTrigger?()
return noErr
}, 1, &eventType, nil, &eventHandlerRef)
RegisterEventHotKey(
UInt32(kVK_ANSI_S),
UInt32(cmdKey | shiftKey),
hotKeyID,
GetApplicationEventTarget(),
0,
&hotKeyRef
)
}
}