无法在appleScript中设置窗口大小

时间:2012-10-17 21:44:17

标签: macos applescript

HY,

我正在编写一个必须设置窗口位置和大小的脚本。

我需要调整大小的应用程序是AIR应用程序。

设定位置没问题,但设定尺寸无效。

我已经简化了此示例的脚本:

tell application "System Events" to tell application process "adl"  
    display dialog (get name of window 1)  
    set position of window 1 to {50, 50}    
    set size of window 1 to {100, 100}  
end tell

你能帮帮我吗?

非常感谢!

3 个答案:

答案 0 :(得分:1)

您可以更改窗口的position,但不能更改size

理由:

1-此窗口对其大小(最小值,最大值或两者)都有约束,因此您无法调整大小低于或高于这些约束。

2-此窗口具有已定义的大小,因此无法缩放。

答案 1 :(得分:0)

编辑:我原来的评论不正确,因此删除了不要混淆任何人。以下脚本确实显示了进程的窗口具有大小和位置属性。

tell application "System Events"
    tell process "Safari"
        properties of window 1
    end tell
end tell

答案 2 :(得分:0)

此代码适用于本机macOS应用程序,并将窗口大小调整为全屏。

tell application "Finder"
    set maximum_size to bounds of window of desktop
end tell

tell application "Terminal"
    set the bounds of the first window to maximum_size
    activate
end tell

我不了解AIR。来源here

相关问题