[AS] Pages et GUIscripting
[AS] Pages et GUIscripting
- Subject: [AS] Pages et GUIscripting
- From: yvan-koenig <email@hidden>
- Date: Wed, 16 Mar 2005 20:53:46 +0100
Hello
I hope that some one may find what is wrong in my handler using
GUIscripting to drive Pages.
-- [SCRIPT]
(* a Pages document is open.
A graphic objet is drawn inline
and the cursor is just after it.
An inspector window is open.
The handler send a backspace to select the object
call the "Inspecteur d'habillage"
to change the "inline object" into a "floating object"
then call "Inspecteur des mesures"
to set object's new coordinates.
The values are put in the corresponding text fields BUT
they don't apply in the main window.
What may be wrong in my code ?
*)
property theApp : "Pages"
property gui99 : "UI element scripting is not enabled. " & ¬
"Check “Enable access for assistive devices”"
set {newX, newY, newRot} to {321, 432, 0}
my positionne({newX, newY, newRot})
-- =====
on positionne({x, y, r})
set actif to (get (my etatDuMenu(8, 9)))
display dialog "" & actif
(* I get odd results. Sometimes, I get "true" when there is NO open
inspector. *)
--if actif is false then my selectMenu(8, 8) (* Affichage, Afficher
l'inspecteur *)
tell application theApp
activate
(* - *)
tell application "System Events"
if UI elements enabled then
tell process theApp
keystroke (ASCII character 8) (* sélectionne l'objet précédant le
curseur *)
tell window 1 (* Inspecteur XXX *)
tell radio group 1
click button 3 (* pour Inspecteur d'habillage *)
end tell -- radio group
end tell -- window 1
set w3 to (get title of window 1) (* Inspecteur d'habillage *)
tell window w3
click radio button 2 of radio group 1 of group 1 (* "Fixé sur la page"
*)
tell radio group 1
click button 6 (* pour Inspecteur des mesures *)
end tell -- radio group
end tell -- window w3
set w6 to get title of window 1 (* Inspecteur des mesures *)
tell window w6
set value of text field 1 of group 1 to (r as text)
set value of text field 1 of group 1 of group 1 to (x as text)
set value of text field 3 of group 1 of group 1 to (y as text)
(*
prévu pour positionner l'objet mais ne fonctionne pas en l'état
Put the values in the fields but they disappear after the
[ end tell -- application theApp] instruction
*)
end tell -- window w6
end tell -- to process
else
my GUImissing()
end if -- UI enabled
end tell -- to System Events
(* I put this error so we may see that correct values are put in
correct fields *)
error 1234
(* comment the error instruction after checking that correct values
are put in correct fields *)
end tell -- application theApp
end positionne
-- =====
on GUImissing()
tell application "System Preferences"
activate
set current pane to ¬
pane "com.apple.preference.universalaccess"
display dialog gui99
end tell -- to System Preferences
end GUImissing
-- =====
on etatDuMenu(mt, mi)
tell application theApp
activate
tell application "System Events"
tell process theApp
tell menu bar 1
set nmbi to (name of menu bar item mt) as text (* 8 = Affichage *)
tell menu bar item nmbi
tell menu nmbi
set pdm to (get enabled of (get properties of menu item mi)) as boolean
end tell -- menu nmbi
end tell --menu bar item nmbi
end tell -- menu bar 1
end tell -- process theApp
end tell -- application System Events
end tell -- application theApp
return pdm
end etatDuMenu
-- =====
on selectMenu(mt, mi)
tell application theApp
activate
tell application "System Events"
tell process theApp
click menu item mi of (menu mt of menu bar 1)
end tell -- process theApp
end tell -- application System Events
end tell -- application theApp
end selectMenu
-- =====
-- [/SCRIPT]
Yvan KOENIG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden