1

少し前に見つけたAppleScriptを変更して、画面/ドック/メニューバーの端から両側に約10pxのマージンがあるように、最前面のウィンドウを配置しました。

set front_app to (path to frontmost application as Unicode text)

tell application "Finder"
    set _b to bounds of window of desktop
    set scrn_width to item 3 of _b
    set scrn_height to item 4 of _b
end tell

tell application front_app
    activate
    set bounds of window 1 to {10, 35, (scrnWidth - 10), (scrnHeight - 80)}
end tell

問題は、ウィンドウごとに個別に実行する必要があることです。一度だけ実行して、各アプリケーションのすべてのウィンドウで動作させたいと思います。

約5つの異なるスクリプトを変更しようとしましたが、エラーが発生します。これが私が持っているものです:

tell application "System Events"
    tell application "Finder"
        set _b to bounds of window of desktop
        set scrn_width to item 3 of _b
        set scrn_height to item 4 of _b
    end tell
    set _windows to get windows of (application processes whose visible is true)
    repeat with this_window in (items of _windows)
        set bounds of this_window to {10, 35, (scrn_width - 10), (scrn_height - 80)}
    end repeat
end tell

どんな助けでもいただければ幸いです!

4

1 に答える 1

3

少し作業をした後、これが私が思いついたものです。

tell application "System Events"
    set frontmostApps to every process whose frontmost is true
    if ((count of frontmostApps) = 0) then return
    set frontmostAppAlias to application file of (item 1 of frontmostApps)
end tell

tell application "Finder" to set desktopBounds to bounds of window of desktop

set screenWidth to item 3 of desktopBounds
set screenHeight to item 4 of desktopBounds

tell application (frontmostAppAlias as string)
    set resizableAppWindows to every window whose resizable is true
    repeat with i from 1 to (count of resizableAppWindows)
        set appWindow to item i of resizableAppWindows
        set bounds of appWindow to {10, 35, (screenWidth - 10), (screenHeight - 80)}
    end repeat
end tell

tell app "System Events"私はもともとブロック内ですべてを実行しようと試みましたが、スクリプト定義からはそうすべきであるにもかかわらず、 esのwindowsはapplication process通常のsと同じ呼び出しを許可していないように見えることがわかりました。windowそれはtell、アプリ自体への直接のブロックにつながりました。

最大サイズ制限が設定されたサイズ変更可能なウィンドウを持つアプリがいくつかあり、エラーが発生する可能性があるため、をブロックでset boundsラップすることをお勧めします。try

于 2013-02-23T10:45:30.913 に答える