(1) I changed the voice because Chantal isn’t available on my machine.
(2) I dislike that but I was forced to urge Safari to quit after displaying a page from Wikipedia.
I don’t understand why but without that, at a second question the copy from the page failed.
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) lundi 7 mars 2016 12:41:59
Ok the only thing that is missing is how to take the text in the buffer (in memory) and tell the script to SAY the text or take the file created by the script and read it…
As is, the script saved the complete page from Wikipedia.
I’m not sure than saying it would be really useful.
I added instructions saying it in the script.
Look at the block :
#=====
# Instructions added to say the grabbed text.
# Code saying the text
with timeout of 3600 seconds
set theText to the clipboard as text
say theText using "Virginie" -- "Chantal"
end timeout
#=====
I tested searching for “cheval”.
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) jeudi 10 mars 2016 12:03:38
It seems that french editors aren’t interested by AppleScript.
I don’t remember ever seeing a book in french about it.
In my library I have I have two books dedicated to AppleScript:
AppleScript: The Definitive Guide, 2nd Edition - 2006
and
Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X (Learn (Apress)) 3rd Edition : 2009
As you may see, they aren’t really up to date but I don’t know more recent books.
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) samedi 12 mars 2016 16:40:58
[i]with timeout
Specifies how long AppleScript waits for a response to a command that is sent to another application.
Syntax
with timeout [ of ] integerExpression second[s] [ statement ]…
end [ timeout ]
Placeholders
integerExpression
The amount of time, in seconds, AppleScript should wait before timing out (and interrupting the command).
statement
Any AppleScript statement.
Examples
The following script tells TextEdit to close its first document; if the document has been modified, it asks the user if the document should be saved. It includes the statement with timeout of 20 seconds, so that if the user doesn’t complete the close operation within 20 seconds, the operation times out.
tell application “TextEdit”
with timeout of 20 seconds
close document 1 saving ask
end timeout
end tell
Discussion
When a command fails to complete in the allotted time (whether the default of two minutes, or a time set by a with timeout statement), AppleScript stops running the script and returns the error “event timed out”. AppleScript does not cancel the operation”it merely stops execution of the script. If you want the script to continue, you can wrap the statements in a try (page 262) statement. However, whether your script can send a command to cancel an offending lengthy operation after a timeout is dependent on the application that is performing the command.
A with timeout statement applies only to commands sent to application objects, not to commands sent to the application that is running the script.
Control Statements Reference
In some situations, you may want to use an ignoring application responses statement (instead of a with timeout statement) so that your script needn’t wait for application commands to complete. For more information, see “considering and ignoring Statements” (page 244).[/i]
I used it here because when I tested the script I got huge Web pages which require a lot of time to be said. So I was afraid that we may get : error “event timed out” if the task require more than the default duration of two minutes.
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) lundi 14 mars 2016 10:43:36