如何从Mac AppleScript中的PID获取要调用的应用程序名称

问题描述 投票:0回答:1

[有一个脚本可让您调整Mac中任何应用的大小。这是代码:

set theApp to "Application Name" 
set appHeight to 1080
set appWidth to 1920

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

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

tell application theApp
      activate
      reopen
      set yAxis to (screenHeight - appHeight) / 2 as integer
      set xAxis to (screenWidth - appWidth) / 2 as integer
      set the bounds of the first window to {xAxis, yAxis, appWidth + xAxis, appHeight + yAxis}
      end tell

我想更改由启动器打开的Java应用程序的大小。当我插入任何应用程序的名称时,它就会起作用。但是,当我插入要调整大小的应用程序名称时,它不起作用。我知道我要调整大小的应用程序的进程ID。有什么办法可以更改此行set theApp to "Application Name"以使用PID代替应用程序名称?谢谢。

macos applescript
1个回答
0
投票

并非所有apps都是AppleScript 可编写脚本,有些不支持bounds property,它们使用position property和[C0 ] 属性。另外,有时您需要系统事件位置大小应用程序 窗口

我使用在size中分配的键盘快捷键和以下示例 AppleScript 代码,以自动调整最前应用程序的窗口。您可以调整code以适应您的需求。

如果<< [最前 应用无法使用FastScripts 属性,它会静静地错误,然后系统事件进行操作。

bounds

注意:我不隶属于FastScript的开发人员,只是一个满意的用户。前十个键盘快捷键

也是免费。
© www.soinside.com 2019 - 2024. All rights reserved.