views:

22

answers:

1

I recognise that Google Chrome & Chromium aren't highly AppleScript enabled yet. But, I was wondering if there was a way to use the "System Events" to hide a particular window or tab?

Here is what I have so far ...

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

end tell

I can access the window I wish to hide but cannot find the command to actually hide it.

Furthermore, if there is a way to repeat through the tabs within the window, that would be even better.

Thanks

A: 

System events can type keyboard commands for you. So look through the menu items of the application and see if there are any keyboard shortcuts to do what you want. For example, every application should have a "Window" menu. In the Window menu is a "Minimize" command with the keyboard shortcut "cmd-m". So you can use that shortcut to hide your windows. Just replace "-- HIDE theWindow command here" with...

keystroke "m" using command down

One other thing. For this to work you must make sure the application is frontmost before doing this so add the following to the beginning of your script.

tell application "Google Chrome" to activate
regulus6633