如何设置一个窗口的索引在applescript中持续(最后面)

时间:2013-09-05 01:58:35

标签: macos indexing applescript

我已经看过很多关于如何在AppleScript中向前发送窗口的帖子,但我希望能够将它发送到后面。我如何写一个可以做到这一点的AppleScript?

4 个答案:

答案 0 :(得分:0)

这会将前取景器窗口移到后面......

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

答案 1 :(得分:0)

set index to 999之类的内容似乎不起作用,但set index to (count windows)确实有效:

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

答案 2 :(得分:0)

也许你实际上并不需要移动任何窗户。也许您可以隐藏您的应用程序,以便您的窗口不显示。由于您不希望窗口位于顶部,因此可以隐藏您的应用程序。它继续运行并做它的事情,但它的窗口没有覆盖任何其他窗口。

只需将“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

答案 3 :(得分:0)

我没有使用过“openFrameWorks”所以我不确定它是如何工作的......

但不是用Applescript重新发明轮子。

您是否可以在“openFrameWorks”中设置窗口级别

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

设置普通窗口:

[awindow setLevel: NSNormalWindowLevel];

但是在其他普通窗口下方设置一个窗口:

[awindow setLevel: NSNormalWindowLevel - 1000];

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