-
Notifications
You must be signed in to change notification settings - Fork 2
/
backmost
executable file
·93 lines (77 loc) · 2.91 KB
/
backmost
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
#!/usr/bin/osascript
-- Send the current frontmost windowed macOS application to the back.
on run argv
set params to {}
repeat with arg in argv
repeat 1 times -- inner loop to allow continuation of outer loop
set arg to arg as text
if arg = "-h" or arg = "--help" then
return "usage: backmost [-h|--help]
-h, --help: print usage help"
end if
copy arg to end of params
end repeat
end repeat
-- TODO: Figure out how to get order of applications in Dock's Application Switcher list.
-- TODO: Move backmost application to back of hidden applications too.
-- TODO: Reduce application window flickering as script executes.
tell application "System Events"
set backmost to name of first application processes where frontmost is true
tell process backmost to set visible to false
set head to name of first application processes where frontmost is true
set others to name of application processes where visible is true and frontmost is false
repeat with other in others
set frontmost of process other to true
end repeat
set frontmost of process head to true
end tell
end run
-- ############################## Junk Code Below ##############################
# application process Dock
# application process Finder
# application process System Events
# application process SystemUIServer
# tell application "System Events" to UI elements of UI element 1 of UI element 1 of UI element 1 of process "Finder"
# tell application "System Events" to name of attributes of process "Dock"
# tell application "System Events"
# # AXRole
# # AXRoleDescription
# # AXTitle
# # AXChildren
# # AXFocusedUIElement
# # AXEnhancedUserInterface
#
# set atts to attributes of process "Dock" where name is "AXChildren"
# log atts
#
# # set atts to attributes of process "Dock"
# # repeat with att in atts
# # set n to name of att
# # log n
# # end repeat
# end tell
# tell application "System Events"
# set elms to UI elements of process "Dock"
# # set orientation of "Dock" to "AXHorizontalOrientation"
# repeat with elm in elms
# set props to properties of elm
# # set orientation of props to "AXHorizontalOrientation"
# # set orientation of elm to "AXHorizontalOrientation"
# end repeat
# end tell
# tell application "Finder"
# name of first file of (path to preferences folder) whose name contains "applescript"
# end tell
# tell application "Dock"
# # AXProcessSwitcherList
# tell item 1
# get properties
# end tell
# end tell
# tell application "System Events"
# # set pp to application processes where visible is false and window is not null
# set pp to application processes where window is {}
# repeat with ppi in pp
# log ppi
# end repeat
# end tell