Re: scripting header/footer in appleworks 6
Re: scripting header/footer in appleworks 6
- Subject: Re: scripting header/footer in appleworks 6
- From: yvan-koenig <email@hidden>
- Date: Wed, 2 Feb 2005 19:14:25 +0100
Here is a more complete responce to AppleWorks 6 footer question.
-- [SCRIPT alimente pied_de_page]
(*
Ne fonctionne que sous Mac OS 10.3.x
Yvan KOENIG, Vallauris (FRANCE)
le 2 février 2005
*)
property french : true (* true = messages français
false = english messages *)
property msg0 : "" -- globale
property msg1 : "" -- globale
property msg2 : "" -- globale
property msg3 : "" -- globale
property msg99 : "" -- globale
property gui99 : "" -- globale
property theApp : "AppleWorks 6"
on run
try
if msg0 is "" then my prepareMessages()
if my quelOS() < "1030" then error msg3 number 8003
my controleGUI()
my controlesDivers()
my metsEnPiedDePage({¬
{"Joyeuses Paques", "Palatino", 18}, ¬
{" Joyeux Noël", "Lucida Grande", 15}, ¬
{" Youpi", "Palatino", 18} ¬
})
on error MsgErr number NroErr
if NroErr is not -128 then
beep 2
tell application (my quiEstAuPremierPlan())
display dialog "" & NroErr & return & MsgErr ¬
with icon 0 ¬
buttons {" Vu "} giving up after 20
end tell -- application
end if
return
end try
end run
-- ==================
on metsEnPiedDePage(LL)
set liste to LL as list
tell application "AppleWorks 6"
set mainDoc to name of front document
select menu item 1 of menu item 1 of menu 2 (* new WP *)
set wptemp to name of front document
select document wptemp
tell document wptemp
repeat with j from 1 to count of liste
set itemJ to (liste's item j) as list
if (count of itemJ) is not 3 then ¬
error msg4 number 8004
set the clipboard to itemJ's item 1
set d1 to get index of selection
select menu item 5 of menu 3 (* Paste *)
set d2 to get index of the selection
select (characters d1 thru d2)
tell selection
try
set font to (itemJ's item 2) as text
end try
try
set size to {itemJ's item 3}
end try
end tell -- selection
my go2EndOfDocGUI()
end repeat -- with j
end tell -- wptemp
select menu item 7 of menu 3 (* Select all *)
select menu item 3 of menu 3 (* cut *)
close document wptemp without saving
tell document mainDoc
set ft to the clipboard
set footer to ft
end tell -- mainDoc
end tell -- AppleWorks
end metsEnPiedDePage
-- ==================
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 strokePluscmdGUI(nb)
tell application "System Events"
if UI elements enabled then
set frontmost of process theApp to true
tell process theApp
key code nb using command down
end tell -- to process
else
my GUImissing()
end if
end tell -- to System Events
end strokePluscmdGUI
-- ==================
(* the used values are OK on french keyboards
check for other ones *)
(*
on insereSautPageGUI()
my strokePluscmdGUI(76)
end insereSautPageGUI
on go2BegOfLineGUI()
my strokePluscmdGUI(70)
end go2BegOfLineGUI
on go2BegOfDocGUI()
my strokePluscmdGUI(77)
end go2BegOfDocGUI
on go2EndOfLineGUI()
my strokePluscmdGUI(66)
end go2EndOfLineGUI
*)
on go2EndOfDocGUI()
my strokePluscmdGUI(72)
end go2EndOfDocGUI
-- ==================
on controleGUI()
tell application "System Events"
if not UI elements enabled then my GUImissing()
end tell -- to System Events
end controleGUI
-- ==================
on controlesDivers()
tell application "AppleWorks 6"
activate
if "6." is not in (version as text) then ¬
error msg0 number 8000
if (count each document) = 0 then ¬
error msg1 number 8001
if (document kind of front document ¬
is not text document) then ¬
error msg2 number 8002
select document 1 (* Utile si le dialogue Recherche est au 1er plan
• Useful if the Search dialog is at front *)
end tell -- Aworks
end controlesDivers
-- ==================
on quelOS()
try
(* «event fndrgstl» = forme canonique de system attribute *)
-- set hexData to «event fndrgstl» "sysv"
set hexData to system attribute "sysv"
set hexString to {}
repeat 4 times
set hexString to ((hexData mod 16) as string) & hexString
set hexData to hexData div 16
end repeat
set OS_version to hexString as string
on error
set OS_version to "0000"
(* retournera "0000" si "system attribute" n'est pas reconnu *)
end try
return OS_version
end quelOS
-- ==================
on quiEstAuPremierPlan()
(* «constant afdregfp» est la forme canonique de frontmost application
*)
-- return (path to «constant afdregfp» as string)
return (path to frontmost application as string)
end quiEstAuPremierPlan
-- ==================
on prepareMessages()
if french is true then
set msg0 to "Ce script n’est pas compatible" & return & ¬
"avec cette version d’AppleWorks." & return & ¬
"Veuillez utiliser une version 6.0" & return & ¬
"ou plus récente..."
set msg1 to "Aucun document ouvert"
set msg2 to "Ce document n’est pas un traitement de textes."
set msg3 to "Ce script requiert la présence" & return & ¬
"de Mac OS 10.3 ou supérieur."
set msg4 to "Paramètres incorrects."
set msg99 to " Vu "
set gui99 to "Le scriptage des éléments d’interface " & ¬
"est désactivé. " & ¬
"Cochez «Activez l’accès pour les périphériques d’aide»"
else
set msg0 to "This script is not compatible" & return & ¬
"with this version of AppleWorks." & return & ¬
"Please use version 6.0" & return & "or higher..."
set msg1 to "No open doc."
set msg2 to "This document is not a word processor."
set msg3 to "This script must be used with" & return & ¬
"Mac OS 10.3 or higher."
set msg4 to "Wrong parameters."
set msg99 to " Oops "
set gui99 to "UI element scripting is not enabled. " & ¬
"Check “Enable access for assistive devices”"
end if
end prepareMessages
-- ==================
-- [/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