AppleScript的 - >激活非脚本化应用程序的窗口 [英] AppleScript -> Activate window of a non-scriptable application

查看:506
本文介绍了AppleScript的 - >激活非脚本化应用程序的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开了2查找窗口A和B,A是在前面而B下方,在下段带来B向前方的最顶层

I have opened 2 "Finder" window A & B, A is in the front while B underneath, the following snippet brings B to the front the topmost:

tell application "Finder"
    activate
    activate window 2
end tell

但是对于那些不支持脚本的应用,刚才提到将不利于code。

But for applications that do not support scripting, the code just mentioned won't help.

激活非脚本应用程序的窗口的任何想法。

Any ideas for activating a window of non-scripting application.

推荐答案

您通常可以求助于在这种情况下系统事件。系统事件知道正在运行的进程的窗口和你通常可以操纵这些窗口。像这样的东西会告诉你一些你可以做的事情。刚玩的code和看到,如果你可以做你想做的。

You can usually turn to system events in these cases. System events knows about the windows of running processes and you can usually manipulate those windows. Something like this will show you some of the things you can do. Just play around with the code and see if you can do what you want.

tell application "System Events"
    tell process "Whatever"
        properties of windows
    end tell
end tell

编辑:一个窗口的属性是它的头衔。所以,你可能能够使用它。这种方法使用的事实,许多应用程序都有一个窗口菜单,并在该菜单中多次窗口的名称列出,您可以通过点击approprite菜单切换窗口。所以,这样的事情可能工作......我的示例使用文本编辑。

One of the properties of a window is its "title". So you might be able to use that. This approach uses the fact that many applications have a "Window" menu and under that menu many times the name of the windows are listed and you can switch windows by clicking the approprite menu item. So something like this might work... my example uses 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

这篇关于AppleScript的 - >激活非脚本化应用程序的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆