最前面のウインドウを最大化して画面いっぱいに表示する AppleScript です。たまには Windows みたいなことをしてみなくなることもある。
このスクリプトの特徴は、
- 前面のアプリケーションを問いません。
- GUI スクリプティングを駆使しているので、AppleScript ユーティリティ/AppleScript エディタで、GUI スクリプティングを ON にしてね。
- Dock の状態/サイズも考慮して、最大化したときのウインドウサイズを賢く計算しているよ。
- 前面のアプリケーションの最前面のウインドウを対象にするので、バックグランドで実行してね。例えば、スクリプトファイトして保存してスクリプトメニューから実行するとか。
コンパイルおよび実行には、
をあらかじめインストールしておく必要があります。ちょっと多いな。ダウンロードパッケージを用意すべきだったか?
Mac OS X 10.5.8 で開発/テストしています。 Mac OS X 10.6 でも動くと思うけど、試していない。問題があったら教えてちょーだい。
property FrontAccess : module
property GUIScriptingChecker : module
property loader : boot (module loader) for me
on run
try
|main|()
on error msg number errno
if errno is not -128 then
activate
display alert msg message "Error Number : " & errno
end if
end try
end run
on |main|()
--
--
if not do() of GUIScriptingChecker then
return
end if
set front_window to (make FrontAccess)'s main_window()
tell application "System Events"
tell application process "Dock"
tell UI element 1
set dock_position to position
set dock_orientation to orientation
set dock_size to value of attribute "AXSize"
end tell
end tell
end tell
tell application "Finder"
set screen_size to bounds of the window of the desktop
end tell
set item 2 of screen_size to 22
if dock_orientation is "AXHorizontalOrientation" then
set item 4 of screen_size to item 2 of dock_position
else
if item 1 of dock_position is 0 then
set item 1 of screen_size to item 1 of dock_size
else
set item 3 of screen_size to item 1 of dock_position
end if
end if
tell application "System Events"
set position of front_window to items 1 thru 2 of screen_size
set size of front_window to {(item 3 of screen_size) - (item 1 of screen_size), (item 4 of screen_size) - (item 2 of screen_size)}
end tell
end |main|