-
Notifications
You must be signed in to change notification settings - Fork 26
/
Recursively-Get-Every-Action.applescript
63 lines (52 loc) · 1.54 KB
/
Recursively-Get-Every-Action.applescript
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
-- this subroutine will get every action of the front macro, even those nested
-- within control statements and groups
global allActions
set allActions to {}
tell application "Keyboard Maestro"
set m to first macro whose selected is true
my getAllActions(m's actions)
end tell
on getAllActions(actionList)
local actionList
tell application "Keyboard Maestro"
get class of actionList
if (class of actionList = list or ¬
class of actionList = action list) and ¬
(count of items of actionList) > 0 then
repeat with act in actionList
my getAllActions(act)
end repeat
else if class of actionList = case entry then
if (count of actionList's actions) > 0 then
my getAllActions(actionList's actions)
end if
else if class of actionList = action then
--set end of allActions to actionList
set end of allActions to a reference to contents of actionList
-- groups
try
if (count of actionList's actions) > 0 then
my getAllActions(actionList's actions)
end if
end try
-- switch statements
try
if (count of actionList's case entries) > 0 then
my getAllActions(actionList's case entries)
end if
end try
--if then actions
try
if actionList's thenactions ≠ missing value then
my getAllActions(actionList's thenactions's actions)
end if
end try
-- if else actions
try
if actionList's elseactions ≠ missing value then
my getAllActions(actionList's elseactions's actions)
end if
end try
end if
end tell
end getAllActions