ous*_*ong 1 applescript window-resize rstudio
我使用脚本编辑器编辑了以下 Applescript,尝试调整 RStudio 窗口的大小,但没有成功。RStudio 已加载,但未正确调整大小。下面附有代码和错误消息。有任何想法吗?我使用的是 macOS Big Sur 11.0.1 和 RStudio 1.3.1073。谢谢!
tell application "RStudio"
activate
set the bounds of the first window to {140, 0, 1160, 775}
end tell
Run Code Online (Sandbox Code Playgroud)
为了在RStudio中设置窗口的位置和大小,您需要使用系统事件以及窗口的和值。propertiespositionsize
AppleScript 代码示例:
\ntell application "System Events" to \xc2\xac\n get properties of window 1 of application process "RStudio"\nRun Code Online (Sandbox Code Playgroud)\n返回,例如:
\n{minimum value:missing value, orientation:missing value, \nposition:{140, 25}, class:window, accessibility description:missing value, \nrole description:"standard window", focused:true, title:"RStudio", \nsize:{1020, 750}, help:missing value, entire contents:{}, \nenabled:missing value, maximum value:missing value, role:"AXWindow", \nvalue:missing value, subrole:"AXStandardWindow", selected:missing value, \nname:"RStudio", description:"standard window"}\nRun Code Online (Sandbox Code Playgroud)\n正如您所看到的,没有bounds property,因此将使用position和,例如:size
tell application "System Events"\n tell application process "RStudio"\n tell window 1\n set position to {140, 25}\n set size to {1020, 750}\n end tell\n end tell\nend tell\nRun Code Online (Sandbox Code Playgroud)\n笔记:
\nlist 属性的项目并不等于 和,而前两项确实等于和实际上需要是,bounds 因为在macOS Big Sur中,菜单栏的 默认值为 24 像素,从而使得与顶部的距离或屏幕到窗口顶部。{140, 0, 1160, 775}{position, size}list position140, 0140, 25height25使用OP 中属性的调整值,以下是数字代表的内容:bounds {140, 25, 1160, 775}
所以虽然 140, 25代表的是position,1160, 775但不是size。size调整后的基数是bounds且是通过从 的值减去 的值{1020, 750}并从的值减去的值得出的。item 1item 3item 2item 4
| 归档时间: |
|
| 查看次数: |
1088 次 |
| 最近记录: |