在 OSX 中,我可以使用 applescript/automator 启动、定位和缩放应用程序吗?

在 OSX 中,我可以使用 applescript/automator 启动、定位和缩放应用程序吗?

我希望能够自动启动我的工作区。我使用多个应用程序,精心放置在两个显示器上,我希望能够通过单击启动我喜欢的布局

我知道如何使用自动脚本启动多个应用程序,现在我只需要将应用程序放在屏幕上它们所属的位置。

非常感谢。

答案1

虽然可以做到这一点,但用脚本来做可能有点太麻烦了。下面是恢复 Firefox 和 iTunes Windows 的部分示例脚本(改编自脚本找到这里

property numFFWindows : 0
property FFPos : {}
property FFSize : {}
property iTunesPos : {}
property iTunesSize : {}

display dialog "Set Window Position or Save Window Position?" buttons {"Restore", "Save"} default button "Restore"
set theResult to result

tell application "System Events"
    if (button returned of theResult is "Restore") then
        -- Restore Settings
        if (numFFWindows > 0) then
            tell process "Firefox"
                repeat with i from 1 to numFFWindows
                    set position of window i to (item i of FFPos)
                    set size of window i to (item i of FFSize)
                end repeat
            end tell
        end if
        if (iTunesPos is not {0, 0}) then
            tell process "iTunes"
                set position of window 1 to iTunesPos
                set size of window 1 to iTunesSize
            end tell
        end if
    else
        -- Save Settings
        tell process "Firefox"
            set numFFWindows to count windows
            set FFPos to {}
            set FFSize to {}
            repeat with i from 1 to numFFWindows
                set end of FFPos to (position of window i)
                set end of FFSize to (size of window i)
            end repeat
        end tell
        tell process "iTunes"
            set iTunesPos to position of window 1
            set iTunesSize to size of window 1
        end tell
    end if
end tell

我建议您查看此实用程序以获得更大的灵活性:

http://cordlessdog.com/stay/

答案2

以下是使用 Applescript 的另一个示例:

tell application "Finder"
    set {0, 0, dtw, dth} to bounds of window of desktop
end tell

tell application "Finder"
    reopen
    activate
    try
        set bounds of window 1 to {0, 22, dtw / 2, dth / 2}
    end try
end tell

tell application "Safari"
    reopen
    activate
    try
        set bounds of window 1 to {0, 22, dtw, dth}
    end try
end tell

tell application "Terminal"
    reopen
    activate
    try
        set position of window 1 to {0, 22}
        set size of window 1 to {dtw / 2, dth - 22}
    end try
end tell

tell application "TextEdit"
    reopen
    activate
    try
        set bounds of window 1 to {dtw / 2, 22, dtw, dth}
    end try
end tell

然而,使用多台显示器需要太多的魔法。

尺寸具有用于将窗口移动到下一个监视器和设置窗口边界的单独操作。

相关内容