-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindowResize.applescript
105 lines (78 loc) · 1.94 KB
/
windowResize.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
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
set window1Size to {500, 500}
set window1Position to {100, 0}
set appName to "Sublime Text"
windowResize(appName, window1Size, window1Position)
getWindowBounds(appName) -- menubar height is 22 pixels
getDockWidth()
on windowResize(appName, window1Size, window1Position)
--tell application appName to activate
if runningProcess(appName) then
try
tell application "System Events" to tell application process appName
tell item 1 of (every window whose subrole is "AXStandardWindow")
set {size, position} to {window1Size, window1Position}
end tell
end tell
return true
on error
return false
end try
else
return false
end if
end windowResize
on getWindowBounds(appName)
if runningProcess(appName) then
try
tell application "System Events" to tell application process appName
tell item 1 of (every window whose subrole is "AXStandardWindow")
set window1Bounds to {size, position}
end tell
end tell
return window1Bounds
on error
return false
end try
else
return false
end if
end getWindowBounds
on getDockWidth()
try
tell application "System Events" to tell process "Dock"
set dock_dimensions to size in list 1
set dock_width to item 1 of dock_dimensions
return dock_width as number
end tell
on error
return 38
end try
end getDockWidth
on dockHideCheck()
tell application "System Events"
tell dock preferences
autohide
end tell
end tell
end dockHideCheck
on dockPosition()
tell application "System Events"
tell dock preferences
screen edge
return result as text
end tell
end tell
end dockPosition
on runningProcess(appName) --return true or false
try
application appName is running
on error -- for can not use "is running"
tell application "System Events"
if application process appName exists then
return true
else
return false
end if
end tell
end try
end runningProcess