cwd*_*cwd 1 window applescript macos
我一直在使用 Better Touch Tool 和 Right Zoom 来最大化窗口到全屏,并将窗口调整到中心,或屏幕的右上角/左上角四分之一。这些应用程序非常漂亮。
我真正想要的是一种预定义一些窗口规范然后将其应用于窗口的方法。例如,窗口可能是 1024 * 768,也可能是距屏幕每个边缘 300 像素。
我知道绿色按钮应该为窗口选择一个合适的大小,但它并不总是有效,并且对于某些应用程序(如 TextMate),我只是希望有一个我可以使用的预设大小/位置。
我可能会以某种方式使用applescript,但有时它似乎需要很长时间才能运行,因此为此使用本机应用程序会更酷。
想法?



保存边界.scpt
try
set text item delimiters to space
tell application (path to frontmost application as text)
set b to (bounds of window 1) as text
set n to name
end tell
do shell script "a=" & quoted form of n & "
f=~/Notes/bounds.txt
touch \"$f\"
sed -i '' \"/^$a: /d\" \"$f\"
echo \"$a: " & b & "\" >> \"$f\""
end try
Run Code Online (Sandbox Code Playgroud)
恢复边界.scpt
try
tell application (path to frontmost application as text)
set n to name
set s to do shell script "sed -En s/^" & quoted form of n & "': (.*)/\\1/p' ~/Notes/bounds.txt"
set bounds of window 1 to words of s
end tell
end try
Run Code Online (Sandbox Code Playgroud)
try
tell application "Finder" to set {0, 0, dtw, dth} to bounds of window of desktop
tell application (path to frontmost application as text) to tell window 1
set b to bounds
set w to (item 3 of b) - (item 1 of b)
set h to (item 4 of b) - (item 2 of b)
set b to {dtw - w, (dth - h) / 2, dtw, dth - (dth - h) / 2}
set bounds to b
end tell
end try
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2089 次 |
| 最近记录: |