G’day scripters.
Runing Sierrs 10.12.5. Xcode ApplescriptOBjC project.
Since the Sierra .4 and .5 updates, my script to select and print from an A4 printer has failed.
In System Preferences, I have two printers, both for the same A3 Epson. One prints to A3, one prints to A4. ('Large Page Printer', 'A4 to Large Page Printer’)
The A3 is called ‘Large Page Printer’, the A4, ‘A4 to Large Page Printer’. The variables assigned are ‘theLargePagePrinter', and ‘theCoverPagePrinter’
The A3 is the Default printer, with A3 paper.
In TextEdit, I have two Printer Presets, one for the A3, one for the A4, both called the same as each Printer name. ('Large Page Printer', 'A4 to Large Page Printer’)
I can open the menu list of each of two buttons, on the Print Dialog Sheet, but the correct A4 printer refuses to be selected from the top menu item, which selects the printer, but the second button works, and selects the A4.
Trouble is, It’s then in the wrong Printer Queue. It should be in the ‘A4 to Large Page Printer’ queue, but isn’t.
I’ve tried Method 2, which is new territory for me, but after 4 hours, cannot get the terminology for either correct, or they simply don’t work.
I can write code in Applescript that works fine, but when transferred to Xcode ASObjC, it fails.
Any pointers please?
Regards
Santa
METHOD 1, FAILS, Print to the A3 printer list, but as A4. I want it to print to the A4 printer list. The first Pop up button ‘sticks’ to Large Page Printer
tell application "TextEdit"
activate
do shell script ("sleep 0.1")
set p to 2
try
tell application "System Events" to tell process "TextEdit"
keystroke "p" using command down
do shell script ("sleep 0.2")
try
click pop up button 1 of sheet 1 of window 1
do shell script ("sleep 0.2")
click menu item (my theCoverPagePrinter) of menu 1 of pop up button 1 of sheet 1 of window 1
end try
do shell script ("sleep 0.2")
try
click pop up button 2 of sheet 1 of window 1
do shell script ("sleep 0.2")
click menu item (my theCoverPagePrinter) of menu 1 of pop up button 2 of sheet 1 of window 1
end try
do shell script ("sleep 0.2")
keystroke return
try
click button "Print" of sheet 1 of window 1
end try
end tell
on error errmsg number errnum
# # tell application "System Events" to display dialog "Actually printing document error " & errmsg & " err number " & errnum giving up after 20
end try
end tell # end if
tell application "TextEdit"
activate
# set (my rtfdPapersize) to (my rtfdPapersize) as text
do shell script ("sleep 0.1")
set p to 2
try
(*with timeout of 4 seconds
print front document with properties {target printer:(my theCoverPagePrinter), copies:1, starting page:1, ending page:3} with print dialog
end timeout*)
end try
try
tell application "System Events" to tell process "TextEdit"
keystroke "p" using command down
do shell script ("sleep 0.2")
try
say 100
do shell script ("sleep 0.4")
with timeout of 6 seconds
(pop up button 1 of sheet 1 of window 1)'s setTitle:(my theCoverPagePrinter)
do shell script ("sleep 0.2")
click
end timeout
say 101
end try
do shell script ("sleep 0.2")
try
say 103
do shell script ("sleep 0.4")
with timeout of 6 seconds
(pop up button 2 of sheet 1 of window 1)'s setTitle:(my theCoverPagePrinter)
do shell script ("sleep 0.2")
click
end timeout
say 104
on error errmsg number errnum
tell application "System Events" to display dialog errmsg
end try
do shell script ("sleep 0.2")
if (my runForOz) then do shell script ("sleep 60")
keystroke return
try
click button "Print" of sheet 1 of window 1
end try
end tell
on error errmsg number errnum
# # tell application "System Events" to display dialog "Actually printing document error " & errmsg & " err number " & errnum giving up after 20
end try
end tell