0

我认识到 Google Chrome 和 Chromium 尚未高度启用 AppleScript。但是,我想知道是否有办法使用“系统事件”来隐藏特定的窗口或选项卡?

这是我到目前为止所拥有的......

tell application "System Events"
tell process "Google Chrome"
    repeat with theWindow in windows
        set thePageName to title of theWindow
        if thePageName contains "ABC" then
            -- HIDE theWindow command here
        end if
    end repeat
end tell

结束告诉

我可以访问我想隐藏的窗口,但找不到实际隐藏它的命令。

此外,如果有一种方法可以重复窗口中的选项卡,那就更好了。

谢谢

4

1 回答 1

1

系统事件可以为您键入键盘命令。因此,请查看应用程序的菜单项,看看是否有任何键盘快捷键可以执行您想要的操作。例如,每个应用程序都应该有一个“窗口”菜单。窗口菜单中有一个“最小化”命令,键盘快捷键为“cmd-m”。因此,您可以使用该快捷方式隐藏您的窗口。只需将“-- HIDE theWindow command here”替换为...

keystroke "m" using command down

另一件事。为此,您必须在执行此操作之前确保应用程序位于最前面,因此将以下内容添加到脚本的开头。

tell application "Google Chrome" to activate
于 2010-06-20T09:05:02.050 回答