Question

I want to print chrome windows automatically (no dialogs) if they fit some sort of URL pattern (e.g. are not of a given set of URLs).

Can you use apple script for that? Could someone share an example? (I do not own a mac so I can't really experiment myself)

Was it helpful?

Solution

set i to 1
tell application "Google Chrome"
    activate
    tell window 1
        repeat with t in tabs
            --if title of t starts with "Example" then
            if {"http://example.com/", "http://aa.com/"} does not contain URL of t then
                set active tab index to i
                tell t to print
                delay 1
                tell application "System Events"
                    click button "Print" of window 1 of process "Chrome"
                    --keystroke return
                end tell
            end if
            set i to i + 1
        end repeat
    end tell
end tell
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top