如何检测firefox的窗口索引?

发布于 2024-11-09 14:25:18 字数 429 浏览 0 评论 0原文

我正在尝试使用 Applescript 获取桌面上 Firefox 的窗口索引(位置)。 我已经到了这里,但我不知道如何继续。有人能给我一些示例代码或线索吗? :-|

tell application "System Events"
    set programs to processes whose visible is true and name is "firefox-bin" or name is "google chrome" or name is "safari"

    repeat with program in programs
        tell window of application program
            #XXX do something   
        end tell
    end repeat
end tell

I'm trying to get the window index (position) firefox on desktop with Applescript.
I got to this far but I don't know how to proceed. Can somebody point to me some example code or clue. :-|

tell application "System Events"
    set programs to processes whose visible is true and name is "firefox-bin" or name is "google chrome" or name is "safari"

    repeat with program in programs
        tell window of application program
            #XXX do something   
        end tell
    end repeat
end tell

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

§对你不离不弃 2024-11-16 14:25:18

您必须知道要识别的窗口的一些属性。在我的示例中,我假设您知道窗口的名称。

set windowName to "some name"
set windowIndex to missing value

tell application "System Events"
    set programs to processes whose visible is true and name is "firefox-bin" or name is "google chrome" or name is "safari"

    repeat with program in programs
        tell program
            set windowNames to name of windows
            repeat with i from 1 to count of windowNames
                if windowName is item i of windowNames then
                    set windowIndex to i
                    exit repeat
                end if
            end repeat
        end tell
    end repeat
end tell

return windowIndex

You have to know some property of the window you want to identify. In my example I assume you know the name of the window.

set windowName to "some name"
set windowIndex to missing value

tell application "System Events"
    set programs to processes whose visible is true and name is "firefox-bin" or name is "google chrome" or name is "safari"

    repeat with program in programs
        tell program
            set windowNames to name of windows
            repeat with i from 1 to count of windowNames
                if windowName is item i of windowNames then
                    set windowIndex to i
                    exit repeat
                end if
            end repeat
        end tell
    end repeat
end tell

return windowIndex
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文