I thought yesterday I’d cracked the problem of how to call other applications from Xcode, but I’ve tried to position two printer Queue windows, and failed.
The first part of the code, opening the apps, and using their processes to open the windows, works, but the second part fails, and does not generate an error.
The code works fine in vanillaApplescript.
property theCoverPagePrinter : "A4 Printer"
property theLargePagePrinter : "Large Page Printer"
my resumeprinters:me
on resumeprinters:sender
set tempPath to path to library folder from user domain
try
set PrinterOne to application (tempPath & "Printers:" & (my theCoverPagePrinter) & ".app" as text)
tell PrinterOne to activate
end try
try
tell application "System Events" to tell process theCoverPagePrinter
click button "Resume" of toolbar 1 of window theCoverPagePrinter
end tell
end try
try
set PrinterTwo to application (tempPath & "Printers:" & (my theLargePagePrinter) & ".app" as text)
tell PrinterTwo to activate
end try
try
tell application "System Events" to tell process theLargePagePrinter
click button "Resume" of toolbar 1 of window theLargePagePrinter
end tell
end try
# Second part, not working, not erroring
try
tell PrinterOne to set theBoundsOne to the bounds of window (my theCoverPagePrinter)
tell PrinterTwo to set theBoundsTwo to the bounds of window (my theLargePagePrinter)
set theWidthOne to (item 3 of theBoundsOne) - (item 1 of theBoundsOne)
set theWidthTwo to (item 3 of theBoundsTwo) - (item 1 of theBoundsTwo)
if the theWidthTwo > theWidthOne then
set theWidthOne to theWidthTwo
end if
set theHeightOne to (item 4 of theBoundsOne) - (item 2 of theBoundsOne)
set theHeightTwo to (item 4 of theBoundsTwo) - (item 2 of theBoundsTwo)
if theHeightTwo > theHeightOne then
set theHeightOne to theHeightTwo
end if
tell PrinterOne to set bounds of window (my theCoverPagePrinter) to {10, 32, 10 + theWidthOne, 32 + theHeightOne}
tell PrinterTwo to set bounds of window (my theLargePagePrinter) to {11 + theWidthOne, 32, 11 + (theWidthOne * 2), 32 + theHeightOne}
on error errmsg number errnum
my displayError("resumeprinters " & errmsg & " number " & errnum & " p = " & p as text)
end try
end resumeprinters: