Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use applescript to hit enter on system printing dialog box?

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)

like image 342
Uri Avatar asked Aug 13 '13 14:08

Uri


1 Answers

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
like image 89
Lri Avatar answered Nov 12 '22 21:11

Lri