-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmykeyboard_mac.py
84 lines (54 loc) · 1.91 KB
/
mykeyboard_mac.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import myosascript
TMPL = 'tell application "System Events" to %s'
TMPL_K = 'tell application "System Events" to key code %s'
TMPL_K_U = 'tell application "System Events" to key code %s using %s'
TMPL_KS = '''
tell application "System Events" to keystroke %s
'''
change_lang_ru = '''
launch application "System Events"
delay 0.1
ignoring application responses
tell application "System Events" to tell process "TextInputMenuAgent"
click menu bar item 1 of menu bar 2
end tell
end ignoring
do shell script "killall System\\\ Events"
delay 0.1
tell application "System Events"
tell process "TextInputMenuAgent"
tell menu bar item 1 of menu bar 2
click menu item "Russian - PC" of menu 1
delay 0.1
end tell
end tell
end tell
ignoring application responses
tell application "System Events" to tell process "TextInputMenuAgent"
click menu bar item 1 of menu bar 2
end tell
end ignoring
do shell script "killall System\\\ Events"
delay 0.1
'''
change_lang_en = '''
tell application "System Events" to tell process "TextInputMenuAgent"
tell menu bar item 1 of menu bar 2
click menu item "U.S." of menu 1
delay 0.1
end tell
end tell
'''
def press_delete(): myosascript.run(TMPL_K % '51')
def press_down(): myosascript.run(TMPL_K % '125')
def press_up(): myosascript.run(TMPL_K % '126')
def press_left(): myosascript.run(TMPL_K % '123')
def press_right(): myosascript.run(TMPL_K % '124')
def press_enter(): myosascript.run(TMPL_K % '76')
def press_return(): myosascript.run(TMPL_K % '36')
def keystroke(val): myosascript.run(TMPL_KS % '"' + val + '"')
def keystroke_return(): myosascript.run(TMPL_KS % 'return')
def brightness_up(): myosascript.run(TMPL_K_U % ('113', 'function down'))
def brightness_down(): myosascript.run(TMPL_K_U % ('107', 'function down'))
def press_esc(): myosascript.run(TMPL_K % '53')
def press_space(): myosascript.run(TMPL_K % '49')