forked from Flamefork/transcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyDiscriminant.m
43 lines (33 loc) · 1.12 KB
/
KeyDiscriminant.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// KeyDiscriminant.m
// Transcode
//
// Created by flamefork on 29.08.08.
// Copyright 2008 Flamefork. All rights reserved.
//
#import "KeyDiscriminant.h"
@implementation KeyDiscriminant
- (void)sendToApplication:(AXUIElementRef)application
{
if (self->modifierKeyState & shiftKey) {
AXUIElementPostKeyboardEvent(application, 0, (CGKeyCode )56, true);
}
if (self->modifierKeyState & controlKey) {
AXUIElementPostKeyboardEvent(application, 0, (CGKeyCode )59, true);
}
if (self->modifierKeyState & optionKey) {
AXUIElementPostKeyboardEvent(application, 0, (CGKeyCode )58, true);
}
AXUIElementPostKeyboardEvent(application, 0, (CGKeyCode )self->virtualKeyCode, true);
AXUIElementPostKeyboardEvent(application, 0, (CGKeyCode )self->virtualKeyCode, false);
if (self->modifierKeyState & optionKey) {
AXUIElementPostKeyboardEvent(application, 0, (CGKeyCode )58, false);
}
if (self->modifierKeyState & controlKey) {
AXUIElementPostKeyboardEvent(application, 0, (CGKeyCode )59, false);
}
if (self->modifierKeyState & shiftKey) {
AXUIElementPostKeyboardEvent(application, 0, (CGKeyCode )56, false);
}
}
@end