Macos 如何设置窗口';s索引到applescript中的最后一个(最后面)

Macos 如何设置窗口';s索引到applescript中的最后一个(最后面),macos,indexing,applescript,Macos,Indexing,Applescript,我看过很多关于如何在applescript中将窗口发送到前面的帖子,但我希望能够将其发送到后面。如何编写一个applescript来完成这项工作?这将把front finder窗口移到后面 tell application "Finder" to set index of front Finder window to (count Finder windows) 类似于将索引设置为999的操作似乎不起作用,但是将索引设置为(计数窗口)可以: tell application "TextEdit

我看过很多关于如何在applescript中将窗口发送到前面的帖子,但我希望能够将其发送到后面。如何编写一个applescript来完成这项工作?

这将把front finder窗口移到后面

tell application "Finder" to set index of front Finder window to (count Finder windows)

类似于
将索引设置为999
的操作似乎不起作用,但是
将索引设置为(计数窗口)
可以:

tell application "TextEdit"
    set index of window 1 to (count windows)
end tell
您还可以打开所有其他窗口:

tell application "System Events" to tell process "TextEdit"
    repeat with w in windows 2 thru -1
        perform action "AXRaise" of w
    end repeat
end tell

也许你实际上不需要移动任何窗户。也许你可以隐藏你的应用程序,这样你的窗口就不会显示了。既然您不希望窗口位于顶部,那么只隐藏应用程序就可以了。它继续运行并完成它的任务,但它的窗口不覆盖任何其他窗口

只需将“Safari”更改为应用程序的名称

set myAppName to "Safari"
tell application myAppName to activate
tell application "System Events"
    -- wait until your application comes forward and then hide it
    repeat
        set p to first process whose frontmost is true
        if name of p is myAppName then
            set visible of p to false -- hide your application
            exit repeat
        end if
        delay 0.2
    end repeat
end tell
编辑:如果隐藏你的应用程序不起作用,那么你可以只按一下“命令”选项卡,这是应用程序切换器命令。基本上,你的应用程序会出现在最前面,然后按键会使以前最前面的应用程序出现在最前面。所以你的窗户不会一直向后,但不会在前面。也许这样行

set myAppName to "Safari"
tell application myAppName to activate
tell application "System Events"
    -- wait until your application comes forward
    repeat
        set p to first process whose frontmost is true
        if name of p is myAppName then exit repeat
        delay 0.2
    end repeat

    -- use the application switcher to bring the previously frontmost application forward
    keystroke tab using command down
end tell
我没有使用“openFrameWorks”,所以我不确定它是如何工作的

而不是用Applescript重新发明轮子

您不能在“openFrameWorks”中设置窗口级别吗

在xcode/Objective-c中,我将使用NSWindow窗口级别

要设置普通窗口,请执行以下操作:

[awindow setLevel: NSNormalWindowLevel];
但在其他正常窗口下方设置一个窗口:

[awindow setLevel: NSNormalWindowLevel - 1000];

这将确保窗口始终低于任何正常应用程序窗口。即使我点击或拖动它。它位于其他窗口之后。

具体在哪个应用程序中?(一个
Finder窗口
有它自己的类)它不是一个Finder窗口-它实际上是我在openFrameworks中开发的一个应用程序,因此它有一个特定的名称,并且不会有这个窗口的任何其他实例,只有其他窗口(它将与max MSP一起运行)。基本上,它将用于为投影到屏幕上的部分性能提供动力,并通过applescript启动,因此当它启动时,我不希望它在已经投影的任何内容上可见。谢谢-请参阅上面的其他说明。我想如果我能将我的应用程序的名称传递给它,并将索引设置为(计算所有窗口)-是否有类似的情况?我想这取决于你的应用程序是否有窗口或文档类。将“Finder”替换为您的应用程序名称,并将Finder窗口替换为窗口或文档。您可能还需要将front替换为window 1或document 1。我已尝试过此操作-窗口捕获网络摄像头,如果窗口最小化,网络摄像头将停止广播(在窗口最小化之前的最后一帧上冻结),并在恢复窗口时继续更新。确定。这只是一个想法。如果我想到别的事,我会告诉你的。祝你好运。嗯,我有另一个主意。我在我的文章中添加了一个编辑部分。是的,那将非常有效!不知道为什么我没想到。谢谢