-
Notifications
You must be signed in to change notification settings - Fork 15
/
applescript.pb
166 lines (153 loc) · 6.27 KB
/
applescript.pb
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
ProcedureC asListShortcuts(command.i)
Protected i
Protected answerString.s
For i = 0 To CountGadgetItems(#gadShortcuts)-1
Protected shortcut.s = GetGadgetItemText(#gadShortcuts,i,0)
Protected state.s
If GetGadgetItemState(#gadShortcuts,i) >= #PB_ListIcon_Checked
state = "1"
Else
state = "0"
EndIf
Protected action.s = GetGadgetItemText(#gadShortcuts,i,1)
Protected cmd.s = GetGadgetItemText(#gadShortcuts,i,2)
answerString + Str(i+1) + ~"\t" + state + ~"\t" + shortcut + ~"\t" + action + ~"\t" + cmd + ~"\n"
Next
Protected answer = CocoaMessage(0,0,"NSString stringWithString:$",@answerString)
ProcedureReturn answer
EndProcedure
ProcedureC asEnableShortcutID(command.i)
Protected argument.i = CocoaMessage(0,command,"evaluatedArguments")
If argument
Protected number = CocoaMessage(0,CocoaMessage(0,argument,"valueForKey:$",@""),"intValue")
If number
PostEvent(#evEnableShortcutID,0,0,0,number)
EndIf
EndIf
EndProcedure
ProcedureC asDisableShortcutID(command.i)
Protected argument.i = CocoaMessage(0,command,"evaluatedArguments")
If argument
Protected number = CocoaMessage(0,CocoaMessage(0,argument,"valueForKey:$",@""),"intValue")
If number
PostEvent(#evDisableShortcutID,0,0,0,number)
EndIf
EndIf
EndProcedure
ProcedureC asToggleShortcutID(command.i)
Protected argument.i = CocoaMessage(0,command,"evaluatedArguments")
If argument
Protected number = CocoaMessage(0,CocoaMessage(0,argument,"valueForKey:$",@""),"intValue")
If number
PostEvent(#evToggleShortcutID,0,0,0,number)
EndIf
EndIf
EndProcedure
ProcedureC asEnableShortcut(command.i)
Static shortcut.s = ""
Protected argument.i = CocoaMessage(0,command,"evaluatedArguments")
If argument
Protected string = CocoaMessage(0,CocoaMessage(0,argument,"valueForKey:$",@""),"UTF8String")
If string
shortcut = PeekS(string,-1,#PB_UTF8)
If Len(shortcut)
PostEvent(#evEnableShortcut,0,0,0,@shortcut)
EndIf
EndIf
EndIf
EndProcedure
ProcedureC asDisableShortcut(command.i)
Static shortcut.s = ""
Protected argument.i = CocoaMessage(0,command,"evaluatedArguments")
If argument
Protected string = CocoaMessage(0,CocoaMessage(0,argument,"valueForKey:$",@""),"UTF8String")
If string
shortcut = PeekS(string,-1,#PB_UTF8)
If Len(shortcut)
PostEvent(#evDisableShortcut,0,0,0,@shortcut)
EndIf
EndIf
EndIf
EndProcedure
ProcedureC asToggleShortcut(command.i)
Static shortcut.s = ""
Protected argument.i = CocoaMessage(0,command,"evaluatedArguments")
If argument
Protected string = CocoaMessage(0,CocoaMessage(0,argument,"valueForKey:$",@""),"UTF8String")
If string
shortcut = PeekS(string,-1,#PB_UTF8)
If Len(shortcut)
PostEvent(#evToggleShortcut,0,0,0,@shortcut)
EndIf
EndIf
EndIf
EndProcedure
ProcedureC asEnableAction(command.i)
Static action.s = ""
Protected argument.i = CocoaMessage(0,command,"evaluatedArguments")
If argument
Protected string = CocoaMessage(0,CocoaMessage(0,argument,"valueForKey:$",@""),"UTF8String")
If string
action = PeekS(string,-1,#PB_UTF8)
If Len(action)
PostEvent(#evEnableAction,0,0,0,@action)
EndIf
EndIf
EndIf
EndProcedure
ProcedureC asDisableAction(command.i)
Static action.s = ""
Protected argument.i = CocoaMessage(0,command,"evaluatedArguments")
If argument
Protected string = CocoaMessage(0,CocoaMessage(0,argument,"valueForKey:$",@""),"UTF8String")
If string
action = PeekS(string,-1,#PB_UTF8)
If Len(action)
PostEvent(#evDisableAction,0,0,0,@action)
EndIf
EndIf
EndIf
EndProcedure
ProcedureC asToggleAction(command.i)
Static action.s = ""
Protected argument.i = CocoaMessage(0,command,"evaluatedArguments")
If argument
Protected string = CocoaMessage(0,CocoaMessage(0,argument,"valueForKey:$",@""),"UTF8String")
If string
action = PeekS(string,-1,#PB_UTF8)
If Len(action)
PostEvent(#evToggleAction,0,0,0,@action)
EndIf
EndIf
EndIf
EndProcedure
Define subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asEnableShortcut",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asEnableShortcut(),"v@")
objc_registerClassPair_(subClass)
subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asDisableShortcut",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asDisableShortcut(),"v@")
objc_registerClassPair_(subClass)
subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asToggleShortcut",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asToggleShortcut(),"v@")
objc_registerClassPair_(subClass)
subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asEnableAction",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asEnableAction(),"v@")
objc_registerClassPair_(subClass)
subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asDisableAction",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asDisableAction(),"v@")
objc_registerClassPair_(subClass)
subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asToggleAction",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asToggleAction(),"v@")
objc_registerClassPair_(subClass)
subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asEnableShortcutID",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asEnableShortcutID(),"v@")
objc_registerClassPair_(subClass)
subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asDisableShortcutID",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asDisableShortcutID(),"v@")
objc_registerClassPair_(subClass)
subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asToggleShortcutID",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asToggleShortcutID(),"v@")
objc_registerClassPair_(subClass)
subClass = objc_allocateClassPair_(objc_getClass_("NSScriptCommand"),"asListShortcuts",0)
class_addMethod_(subClass,sel_registerName_("performDefaultImplementation"),@asListShortcuts(),"v@")
objc_registerClassPair_(subClass)