Generic Applescript for printing

Discussion in 'Mac Programming' started by fred6633, Jul 1, 2011.

  1. macrumors newbie

    Joined:
    Sep 19, 2010
    #1
    Hello,

    This script works:

    tell application "Pages"
    print the front document with properties {copies:1, error handling:standard} without print dialog
    end tell

    However, I would like a generic script that prints the front document in the active application, so I don't have to create one script for Pages, one for TextEdit, one for Preview and so on.

    Fred
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Code:
    [b]set[/b] [color=#408000]appName[/color] [b]to[/b] [i][color=#0000ff]missing value[/color][/i]
    [b]tell[/b] [i][color=#0000ff]application[/color][/i] "System Events"
        [b]set[/b] [color=#408000]appName[/color] [b]to[/b] [color=#6c05d3]name[/color] [b]of[/b] [b]the[/b] [b]first[/b] [i][color=#0000ff]process[/color][/i] [b]whose[/b] [color=#6c05d3]frontmost[/color] [b]is[/b] [color=#4a1e7f]true[/color]
    [b]end[/b] [b]tell[/b]
    [b]tell[/b] [i][color=#0000ff]application[/color][/i] [color=#408000]appName[/color]
        [b][color=#0000ff]print[/color][/b] [b]the[/b] [b]front[/b] [i][color=#0000ff]document[/color][/i] [color=#0000ff]with properties[/color] {[color=#6c05d3]copies[/color]:1, [color=#6c05d3]error handling[/color]:[color=#4a1e7f]standard[/color]} [b]without[/b] [color=#0000ff]print dialog[/color]
    [b]end[/b] [b]tell[/b]
     

Share This Page