AppleScript user interaction unter OS X 10.11
RagTime unterstützt umfangreiche Möglichkeiten zur Fernsteuerung über AppleScript. Diese Skripte erlauben beispielsweise auch Mitteilungen an den Anwender. In OS X 10.11 können aber die sog. user interactions nicht mehr direkt ausgeführt werden.
Bis OS X 10.10 kann man problemlos ein Skript wie dieses nutzen:
tell application "RagTime 6.6"
activate
set dlgResult to button returned of (display dialog "Script ausführen?" buttons {"Ja", "Nein"} default button 2)
set cell "A1" of table 1 of document 1 to dlgResult
end tell
Ab OS X 10.11 geht das nicht mehr, da RagTime Berechnungen im Hintergrund ausführt, was auch bei laufenden Skripten der Fall ist. Hier kommt es zum Syslog:
2016-05-03 16:16:51 asl fungus RagTime[31784]: This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release. ...
was in RagTime dann zu einem Dauerläufer führt.
Die Lösung für dieses Problem ist die Verwendung der "System Events" für user interactions, wie
- choose application
- choose color
- choose file
- choose file name
- choose folder
- choose from list
- choose remote application
- choose URL
- display alert
- display dialog
Die folgenden Beispiele zeigen, wie man die "System Events" nutzen kann um trotzdem erfolgreich mit dem Anwender über AppleScript zu kommunizieren. Es wird hier jeweils die Zelle A1 im ersten Rechenblatt des Dokuments verändert. Eine Beispielsdatei ist als Anhang zu diesem Artikel angefügt.
display dialog
tell application "RagTime 6.6"
activate
set dlgResult to "foo"
tell application "System Events"
activate
set dlgResult to button returned of (display dialog "Script ausführen?" buttons {"Ja", "Nein"} default button 2)
end tell
set cell "A1" of table 1 of document 1 to dlgResult
end tell
choose from list
tell application "RagTime 6.6"
activate
set dlgResult to "foo"
tell application "System Events"
activate
set dlgResult to (choose from list {"Banana", "Pear", "Quince"} with title "a List" with prompt "Select an item" default items {"Quince"})
end tell
activate
if dlgResult = false then
set dlgResult to "" -- canceled
else
set dlgResult to item 1 of dlgResult
end if
set cell "A1" of table 1 of document 1 to dlgResult
end tell
Thomas Eckert
RagTime Support
| Anhang | Größe |
|---|---|
| User Interaction.rtd | 21.6 KB |
