AppleScript でダイアログを作成し、ユーザの入力に応じて動作するようにできます。たとえば、以下のスクリプトを書き入れて、ふるまいを試してみてください。
- -- AppleScript
- -- Use a dialog to enter user defined information into an applescript.
- -- ダイアログを使い、ユーザの定めるデータを AppleScript に取り込みます。
- -- There are two feedbacks possible 'text' and "choice of buttons".
- -- 「テキスト」と「ボタン選択」による2つのフィードバックが利用可能です。
- -- The returned information can be used to define corresponding variables.
- -- 返されたデータは該当する変数を定義するのに使えます。
- -- The number of buttons may not exceed three.
- -- ボタンの数は3つを超えないように。
- -- In the three examples below it is shown how to use text return, button return, and both.
- -- 以下の3つの例では、テキスト、ボタン、テキスト&ボタンの使い方について示しています。
- activate
- display dialog "Test dialog: type something below" default answer "Hello World!" buttons {"A", "B", "C"} default button "B"
- set theText to (the text returned of the result)
- display dialog "Test dialog: type something below" default answer "Hello World!" buttons {"A", "B", "C"} default button "B"
- set theButton to (the button returned of the result)
- display dialog "Test dialog: type something below" default answer "Hello World!" buttons {"A", "B", "C"} default button "B"
- set {theText, theButton} to {the text returned of the result, the button returned of the result}
この例にあるコマンド「activate」には解説が必要です。AppleScript を実行するよう要請されるとTeXShop は、別のプログラムを呼び出してスクリプトを実行します。そのプログラム──Scriptrunner は、TeXShop に組み込まれています。スクリプトで作成したダイアログはすべて、TeXShop ではなく Scriptrunner で表示されます。「activate」コマンドは Scriptrunner を前面に持ってくるので、ダイアログは他のウインドウよりも手前に表示されます。