2010-09-07 20 views
2

我已打开2“搜索”窗口甲& B的窗口中,A是在前面而B下方,下面的片段带来B到前部的最顶端的:的AppleScript - >激活的非编写脚本的应用

tell application "Finder" 
    activate 
    activate window 2 
end tell 

但是对于不支持脚本的应用程序,刚刚提到的代码将无济于事。

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

回答

4

在这些情况下,您通常可以转向系统事件。系统事件知道正在运行的进程的窗口,您通常可以操作这些窗口。像这样的东西会告诉你一些你可以做的事情。只是玩弄代码,看看你是否可以做你想做的。

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

编辑:一个窗口的属性是它的“称号”。所以你可以使用它。这种方法使用的事实是,许多应用程序有一个“窗口”菜单,并在该菜单下多次列出窗口的名称,您可以通过点击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 
+0

感谢regulus6633,但我看到结果没有分别为“Finder”和另一个应用程序运行您的代码的区别。 – user435657 2010-09-08 06:35:31

+0

我在我的文章中添加了另一种方法。也许它会有所帮助。 – regulus6633 2010-09-08 21:27:27

+0

兴奋,你的方法确实有效,至少对我的应用程序!非常感谢! – user435657 2010-09-09 00:57:36