macos - 在 OS X 中使用 AppleScript 在窗口上设置的窗口边界被忽略

标签 macos applescript

我正在尝试创建一个小的 AppleScript 来在我的屏幕上创建和移动一些终端窗口。我遇到的问题是,在某些情况下,OS X 似乎忽略了我设置的界限。

使用 AppleScript 编辑器:

tell application "Terminal" to set the bounds of the first window to {0, 50, 600, 700}
tell application "Terminal" to get the bounds of the first window

在事件日志中显示以下内容:
tell application "Terminal"
    activate
    set bounds of window 1 to {0, 50, 600, 700}
    get bounds of window 1
        --> {0, 22, 600, 672}
end tell
Result:
{0, 22, 600, 672}

目视检查脚本运行时创建的窗口显示结果边界是窗口正在使用的边界。

有任何想法吗?

编辑:运行 10.6.3。我的屏幕尺寸为 1280 X 800。Finder 报告桌面窗口的边界为 {0, 0, 1280, 800}

最佳答案

有时当告诉应用程序设置边界不起作用时,告诉系统事件更改位置和大小属性会:

tell application "System Events" to tell process "Live"
    set position of window 1 to {0, 50}
    set size of window 1 to {600, 650}
end tell

关于macos - 在 OS X 中使用 AppleScript 在窗口上设置的窗口边界被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2777927/

相关文章:

cocoa - 如何以编程方式确定正在运行的 Mac OS X 版本?

java - 无法从应用程序 : Plist file doesn't exist: 中提取 Info.plist

macos - 为什么要在 Docker 容器中安装 Linux dist?

xcode - 有人知道xcode文件 "InfoPlist.strings (English)"是什么吗?

python - 在不使用 osascript 或 appscript 的情况下从 Python 调用 AppleScript?

linux - AWK 脚本 : Finding number of matches that each element in Col2 has in Col1

macos - 如何确定 Mac OS X 中的文件或文件夹是否隐藏?

bash - osascript 中的多行字符串

objective-c - 如何使用 [[NSAppleScript alloc] initWithSource : 检查应用程序是否正在运行

python - 使用 applescript (重新)启动 python 脚本