如何检测firefox的窗口索引



我正试图用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

您必须知道要标识的窗口的某些属性。在我的例子中,我假设您知道窗口的名称。

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

最新更新