如何从 Mac AppleScript 中的 PID 获取要调用的应用程序名称
How to get Application Name To Call from PID in Mac AppleScript
有一个脚本可以让您调整 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 而不是应用程序名称?
谢谢
并非所有 apps 都是 AppleScript scriptable 并且有些不支持 bounds
属性,他们用position
属性和size
属性。此外,有时您需要 System Events 到 position 和 size 和 app's window.
我使用在 FastScripts 中分配的 键盘快捷键 以及以下 示例 AppleScript code 自动调整 frontmost 应用程序的 window。您可以调整 代码 以满足您的需要。
如果frontmost app无法使用bounds
属性 它默默地 错误 ,然后 系统事件 执行它。
tell application "System Events"
set frontmostProcess to name of process 1 whose frontmost is true
end tell
try
tell application frontmostProcess
set bounds of window 1 to {0, 22, 1136, 844}
end tell
on error
tell application "System Events" to tell application process frontmostProcess
set position of window 1 to {0, 22}
set size of window 1 to {1136, 822}
end tell
end try
注意:我不隶属于FastScript的开发者,只是一个满意的用户。前十个 键盘快捷键 也是 免费 。
有一个脚本可以让您调整 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 而不是应用程序名称?
谢谢
并非所有 apps 都是 AppleScript scriptable 并且有些不支持 bounds
属性,他们用position
属性和size
属性。此外,有时您需要 System Events 到 position 和 size 和 app's window.
我使用在 FastScripts 中分配的 键盘快捷键 以及以下 示例 AppleScript code 自动调整 frontmost 应用程序的 window。您可以调整 代码 以满足您的需要。
如果frontmost app无法使用bounds
属性 它默默地 错误 ,然后 系统事件 执行它。
tell application "System Events"
set frontmostProcess to name of process 1 whose frontmost is true
end tell
try
tell application frontmostProcess
set bounds of window 1 to {0, 22, 1136, 844}
end tell
on error
tell application "System Events" to tell application process frontmostProcess
set position of window 1 to {0, 22}
set size of window 1 to {1136, 822}
end tell
end try
注意:我不隶属于FastScript的开发者,只是一个满意的用户。前十个 键盘快捷键 也是 免费 。