Dear Brett
If you search the archive for Yvan Koenig, he has posted some useful hints on UI scripting. I am not a programmer by any means but his approach is to query all the elements, (which would get the window name) and then assign these to variables Below is a portion of the script which he sent me as an example
(* Si le GUIscripting est actif, ouvre le dialogue "Format d'impression" clique sur le bouton "Paysage" et presse Retour.
• If GUIscripting active, open the dialog "Page Settings" click in the button "Landscape" and press Return *) on modePaysage() tell application "AppleWorks 6" activate select document 1 (* tell document 1 end tell *) end tell -- application "AppleWorks 6" tell application "System Events" if UI elements enabled then tell process "AppleWorks 6" click menu item 15 of menu (2 + 1) of menu bar 1 (* attention, pour le process "AppleWorks 6", le menu Pomme a le numéro 1 alors qu'il a le numéro 0 en AppleScript standard De ce fait ici le menu "Fichier" a le numéro 3
• CAUTION, for process AppleWorks 6, the Apple Menu is #1 while it is #0 in standard Applescript. So here, the File menu is numbered #3 *) set nmi to get name of menu item 15 of menu (2 + 1) of menu bar 1 (* récupère le nom de l'article de menu •Grab the name of menu item *) set nw to text 1 thru -2 of nmi (* récupère le nom de la fenêtre • Grab the name of the window *) (* -- set wProps to (get properties of every UI element of window nw) I used this instruction to get informations about UI elements available in the dialog
{{position:{733, 480}, maximum:missing value, name:"Format d’impression", size:{131, 16}, subrole:missing value, class:static text, minimum value:missing value, enabled:true, selected:missing value, role:"AXStaticText", help:missing value, title:missing value, value:"Format d’impression", orientation:missing value, description:"texte", focused:missing value},¬ {position:{576, 742}, maximum:missing value, name:missing value, size:{444, 55}, subrole:missing value, class:UI element, minimum value:missing value, enabled:true, selected:missing value, role:"AXUnknown", help:missing value, title:missing value, value:missing value, orientation:missing value, description:"inconnu", focused:missing value},¬ {position:{652, 521}, maximum:missing value, name:"Réglages :", size:{66, 20}, subrole:missing value, class:static text, minimum value:missing value, enabled:true, selected:missing value, role:"AXStaticText", help:missing value, title:"Réglages :", value:"Réglages :", orientation:missing value, description:"texte", focused:missing value},¬ {position:{596, 545}, maximum:missing value, name:missing value, size:{404, 194}, subrole:missing value, class:UI element, minimum value:missing value, enabled:true, selected:missing value, role:"AXUnknown", help:missing value, title:missing value, value:missing value, orientation:missing value, description:"inconnu", focused:missing value},¬ {position:{727, 520}, maximum:missing value, name:missing value, size:{244, 20}, subrole:missing value, class:pop up button, minimum value:missing value, enabled:true, selected:missing value, role:"AXPopUpButton", help:missing value, title:missing value, value:"Attributs de page", orientation:missing value, description:"bouton de menu local", focused:missing value}}
A lot of elements are "missing":
three are embedded in UI element 2 button "Help" button "OK" button "Cancel"
eleven are embedded in UI element 4 static text "Pour :" and linked menu static text "EPSON SP830U Series (1,1)" static text "Papier :" and linked menu static text "21,00 cm x 29,70 cm" static text "Orientation :" and the linked group of three radio buttons static text "Échelle :" and the linked textField static text "%"
Is it a safe way to let the script grab the properties of these embedded elements (mainly the orientation buttons) ?
*) set {x4, y4} to (get position of UI element 4 of window nw) set {sx4, sy4} to (get size of UI element 4 of window nw) set ofP to sx4 div 2 (* La structure de cet objet n'est pas documentée mais le bouton Paysage est à mi-largeur, sa position verticale est apparemment constante (120) dans l'objet et sa hauteur est également constante (38), et le décalage des deux autres boutons est de 71 pixels. Par sécurité je clique à mi hauteur du bouton (120 +19 = 139)
• The structure of this item is not documented but the landscape button is in the middle of the width Its vertical position is a constant (120) in the item and its height is fixed too (38), and the offset to the two others buttons is 71 pixels. For safe I choosed to click at mid-height in the button (120 + 19 = 139 )*) (* click at {x4 + ofP - 71, y4 + 139} (* dans le bouton "Portrait" *) *) click at {x4 + ofP, y4 + 139} (* dans le bouton "Paysage-Landscape" *) (* click at {x4 + ofP + 71, y4 + 139} (* dans le bouton "Paysage inversé-Landscape reversed" *) *) keystroke return end tell -- process "AppleWorks 6" else my GUImissing() end if -- UI enabled end tell -- application System Events end modePaysage
David Hage Conehead Music Ltd
On 18 Jan 2006, at 06:53, Mark Butler wrote: Hey Brett,
Before you waste a bunch of time like I did... I couldnt click the print button in Quark so GUI scripting the print dialog was a waste of time. Quark's print command is broken in Tiger so scripting that dosent work. Even before Tiger you couldnt set a custom page size without editing the ppd and taking all the page sizes out. This work around uses the export pdf. You can set the pdf export to only go to ps so it is somewhat useable although I have seen some problems with images in certain rips. You can set in the preferences of Quark to use a post processor for the pdf's so I dont think this touches Jaws (pdf engine Quark uses) at all.
I picked this up somewhere think it was the Quark forums...
|