我打开了2个"Finder"窗口A和B,A在前面而B在下面,下面的代码片段将B带到最顶层的前面:
tell application "Finder"
activate
activate window 2
end tell
Run Code Online (Sandbox Code Playgroud)
但对于不支持脚本的应用程序,刚才提到的代码无济于事.
有关激活非脚本应用程序窗口的任何想法.
在这些情况下,您通常可以转向系统事件.系统事件了解正在运行的进程的窗口,您通常可以操作这些窗口.这样的事情会告诉你一些你可以做的事情.只需使用代码,看看你是否可以做你想做的事.
tell application "System Events"
tell process "Whatever"
properties of windows
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
编辑:窗口的一个属性是它的"标题".所以你可以使用它.这种方法使用的事实是许多应用程序都有一个"窗口"菜单,并且在该菜单下多次列出了窗口的名称,您可以通过单击approprite菜单项来切换窗口.所以像这样的东西可能有用...我的例子使用TextEdit.
tell application "TextEdit" to activate
tell application "System Events"
tell process "TextEdit"
set windowTitle to title of window 2
click menu item windowTitle of menu 1 of menu bar item "Window" of menu bar 1
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9730 次 |
最近记录: |