2013-02-03 18 views
2

我試圖自動化一些硬打印。打印文檔的多個副本Applescripting a printer's app

我已經可以打印訪問打印機的應用這樣一個文件的一個副本:

tell application "hp LaserJet 2300 series (BDB806)" --my printer's app, could be any other model 
    print myFile 
end tell 

這段代碼工作。

但是,當我嘗試打印多個副本時,它變得棘手。根據打印機的應用詞典,我應該可以通過這樣做來實現它:

tell application "hp LaserJet 2300 series (BDB806)" 
    print myFile with properties {copies:n} -- n being an integer 
end tell 

但是這不起作用。

請讓我知道我做錯了什麼。

回答

0

發生在相同的給我這個代碼:

set d to ((path to home folder) as string) & "Desktop:" & "untitled.txt" 
set n to 3 
tell application "EPSON WP-4595 Series" 
    print d with properties {copies:n} 
end tell 

只打印一份。

據我知道沒有什麼是錯的代碼,或許真的是錯誤的使用AppleScript ..

不是很優雅,但你總是可以做

... 
    repeat n times 
     print d 
    end repeat 
+0

@保羅感謝,可能是一個錯誤然後在AppleScript中,我已經閱讀了有關'{copies:n}'參數的類似問題。我曾使用過重複聲明作爲未完成的解決方案。問題在於打印大量副本的速度很慢,因爲打印機將每個副本作爲單獨的作業。 – Guillaume

+0

您還可以使用它的應用程序打開文檔,並執行一些GUI腳本來打開打印對話框,設置副本,打印。但這是一個非常糟糕的做法。 – Paolo