Applescript-Lösung:
Während Brothers 'P-touch Editor (v5.1) Applescript nicht unterstützt, können Sie die Anwendung "System Events" verwenden, um einem Prozess mitzuteilen, dass er Aufgaben ausführen soll. Dies funktioniert durch die Manipulation der GUI, persönlich mag ich diesen Ansatz nicht, aber es funktioniert.
Um das zu tun, was in der Frage gesagt wird, habe ich das folgende Applescript geschrieben (dies wurde nur in einer relativ kontrollierten Umgebung unter OS X 10.10.1 (Yosemite), mit P-touch Editor v5.1 und Applescript v2 getestet .4).
# set the location of the 'database' set prepareShipments to "/some/dir/list.csv" # set variables to identify the label the needs to be printed and the list containing the dataset set templateDir to "/some/other/dir" set templateName to "someTemplate" set templateExt to ".lbx" # open the template, my default application for this filetype is "P-touch Editor" do shell script "open " & templateDir & templateName & templateExt # "System Events" will tell its process "P-touch Editor" to perform our desired tasks tell application "System Events" #hold-up while application is loading and set it to the 'frontmost' or active process repeat until frontmost of process "P-touch Editor" is true tell process "P-touch Editor" to set frontmost to true end repeat # actually start telling P-touch Editor what to do: tell process "P-touch Editor" # wait for template to open.. repeat until exists window templateName end repeat # 'connect...' to database, if already connected (then the menu item is not clickable), choose to 'change...' the database instead click menu item "Connect..." of menu "Database" of menu item "Database" of menu "File" of menu bar item "File" of menu bar 1 click menu item "Change..." of menu "Database" of menu item "Database" of menu "File" of menu bar item "File" of menu bar 1 # hold-up until dialog window exists repeat until exists window "Open Database" end repeat # enter the location of the new 'database' set value of text field 1 of window "Open Database" to prepareShipments # my csv file does not contain headers. So uncheck the 'Header Row Contains Field Names' box if value of checkbox "Header Row Contains Field Names" of window "Open Database" is 1 then click checkbox "Header Row Contains Field Names" of window "Open Database" end if # just keep swimming... click button "Next" of window "Open Database" click button "OK" of window "Open Database" # database is connected to template; time to print click menu item "Print..." of menu "File" of menu bar item "File" of menu bar 1 click button "Print" of sheet 1 of window templateName # printjob has been issued, time to wrap up. Close the window click menu item "Close" of menu "File" of menu bar item "File" of menu bar 1 # changes have been made, give some time for the 'save changes' dialog to pop up. delay 0.5 # if it did pop up, tell it to not save the changes (using short-cut '[cmd] + [down arrow] + d') if exists window 1 then if name of window 1 = templateName then keystroke "d" using command down end if # do a regular quit, we do not know if any other unsaved windows are open, or whether we want to keep those changes, so do not force any 'do not save' actions. click menu item "Quit P-touch Editor" of menu "P-touch Editor" of menu bar item "P-touch Editor" of menu bar 1 end tell end tell #now that printjob is finished and P-touch Editor is quit, add some additional script for cleaning the inventory, moving printed .csv files to archived folder.
Sehen Sie sich die Kommentare im obigen Skript an, um zu sehen, was es bewirkt. Natürlich könnte dies verbessert werden, um mehr Fälle zu berücksichtigen, aber ich werde das persönlich in einer kontrollierten Umgebung durchführen. Höchstwahrscheinlich ein Mac Mini, der an den Drucker angeschlossen ist.
Alternative Antwort (besser geeignet für Windows-Benutzer):
Wie von @Hannu erwähnt, gibt es auf der Brother-Website ein „Labeling SDK“ namens „b-PAC SDK“. Es würde technisch eine automatische Datenbankverbindung mit einer der in diesem Dokument beschriebenen Methoden zulassen, erfordert jedoch eine Windows-Umgebung. Da mein Webserver unter Linux und alle meine Clients unter OS X laufen, kann ich das momentan nicht weiter testen. Es scheint jedoch eine "elegantere" Lösung zu sein. Da ich kein Scripting mag, um GUI zu manipulieren. Es scheint sehr ineffizient zu sein.