• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Is there an easier way?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is there an easier way?


  • Subject: Is there an easier way?
  • From: Brian Christmas <email@hidden>
  • Date: Fri, 05 Dec 2014 02:36:01 +1100

G’day scripters

I’m trying to build a list of every paper size available to any given printer, set from a printer list of existing printers.

I’m using the print dialog box from Text Edit, with the code below.

It’s very slow, so I’m wondering if there’s any way of obtaining the list without opening every paper menu?

Any help appreciated.

Regards

Santa

on setUpPaperSize(selectedPrinter)
tell application "TextEdit"
activate
tell application "System Events" to tell process "TextEdit"
if not (exists window 1) then click menu item "New" of menu 1 of menu bar item "File" of menu bar 1
set x to 0
repeat until exists window 1
set x to x + 1
if x = 20 then exit repeat
tell current application to delay 0.1
end repeat
select window 1
tell current application to delay 0.1
try
keystroke "P" using command down
end try
set x to 0
repeat until exists sheet 1 of window 1
set x to x + 1
if x = 20 then exit repeat
tell current application to delay 0.1
end repeat
try
click pop up button 2 of sheet 1 of window 1
repeat until exists menu 1 of pop up button 2 of sheet 1 of window 1
tell current application to delay 0.1
end repeat
try
click menu item (selectedPrinter as text) of menu 1 of pop up button 2 of sheet 1 of window 1
on error errmsg
click menu item 1 of menu 1 of pop up button 2 of sheet 1 of window 1
end try
click pop up button 3 of sheet 1 of window 1
repeat until exists menu 1 of pop up button 3 of sheet 1 of window 1
tell current application to delay 0.1
end repeat
set mainPaperList to ""
set menucount to (count of menu items of menu 1 of pop up button 3 of sheet 1 of window 1) as list
repeat with x from 1 to menucount
click menu item x of menu items of menu 1 of pop up button 3 of sheet 1 of window 1
if exists menu 1 of menu item x of menu items of menu 1 of pop up button 3 of sheet 1 of window 1 then
set tempMenu to (every menu item of menu 1 of menu item x of menu 1 of pop up button 3 of sheet 1 of window 1) as list
repeat with y from 1 to count of tempMenu
set mainPaperList to mainPaperList & item y of tempMenu & return as text
end repeat
else
set mainPaperList to mainPaperList & menu item x of menu items of menu 1 of pop up button 3 of sheet 1 of window 1 & return as text
end if
end repeat
repeat while exists menu item 1 of menu 1 of pop up button 3 of sheet 1 of window 1
tell current application to delay 0.1
try
click menu item 1 of menu 1 of pop up button 3 of sheet 1 of window 1
try
click menu item 1 of menu 1 of menu item 1 of menu 1 of pop up button 3 of sheet 1 of window 1
end try
end try
end repeat
on error
set mainPaperList to {}
end try
click button "Cancel" of sheet 1 of window 1
end tell
quit
set paperSizeList to "No Paper Selected" & return as text
repeat with x from 1 to count of mainPaperList
set eachSize to item x of mainPaperList as text
if eachSize as text is not "missing value" and "Custom" as text is not in eachSize as text then set paperSizeList to paperSizeList & eachSize & return as text
end repeat
end tell
return paperSizeList
end setUpPaperSize





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Is there an easier way?
      • From: Stan Cleveland <email@hidden>
  • Prev by Date: Re: Problem accessing secondary script
  • Next by Date: transparent window won't activate
  • Previous by thread: Re: Problem accessing secondary script
  • Next by thread: Re: Is there an easier way?
  • Index(es):
    • Date
    • Thread