1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-10 17:08:39 +00:00
This commit is contained in:
Toxblh 2019-05-09 22:14:48 +01:00
parent 5a8117ac7f
commit 40fa61fcb5
4 changed files with 16 additions and 3 deletions

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.20.2</string>
<string>0.20.3</string>
<key>CFBundleVersion</key>
<string>197</string>
<key>LSApplicationCategoryType</key>

View File

@ -51,7 +51,7 @@ class SupportedTypesHolder {
private var supportedTypes: [String: ParametersDecoder] = [
"escape": { _ in (
item: .staticButton(title: "esc"),
action: .keyPress(keycode: 53),
action: .keyPressSession(keycode: 53),
longAction: .none,
parameters: [.align: .align(.left)]
) },
@ -459,6 +459,7 @@ enum ActionType: Decodable {
case none
case hidKey(keycode: Int32)
case keyPress(keycode: Int)
case keyPressSession(keycode: Int)
case appleScript(source: SourceProtocol)
case shellScript(executable: String, parameters: [String])
case custom(closure: () -> Void)

View File

@ -23,6 +23,16 @@ extension KeyPress {
let keyDown = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: true)
let keyUp = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: false)
let loc: CGEventTapLocation = .cghidEventTap
keyDown?.post(tap: loc)
keyUp?.post(tap: loc)
}
func sendSession() {
let src = CGEventSource(stateID: .hidSystemState)
let keyDown = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: true)
let keyUp = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: false)
let loc: CGEventTapLocation = .cgAnnotatedSessionEventTap
keyDown?.post(tap: loc)
keyUp?.post(tap: loc)

View File

@ -319,6 +319,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
return { HIDPostAuxKey(keycode) }
case let .keyPress(keycode: keycode):
return { GenericKeyPress(keyCode: CGKeyCode(keycode)).send() }
case let .keyPressSession(keycode: keycode):
return { GenericKeyPress(keyCode: CGKeyCode(keycode)).sendSession() }
case let .appleScript(source: source):
guard let appleScript = source.appleScript else {
print("cannot create apple script for item \(item)")