変数をapplescriptに渡したいです。たとえば、Cocoa アプリ (cocoa-applescript アプリではない) のテキスト フィールドにいくつかの単語を入力すると、後で使用するために Applescript の変数になります。Applescript を使用して、一部のソフトウェアにいくつかのファイルを実行するように指示します。
Applescript から Objective C に文字列を渡す方法を試してみました。initialwithSource を使用して、 applescriptの最初の行を追加できます。私は長い文章を書かなければなりません。また、AppleScript が既にある場合は、それらを結合する必要があります。または、以下のようにすべてのスクリプトを Cocoa で作成する必要があります。無意味だし、うまくいかないこともある。
NSString *SlideURL = [NSString stringWithFormat:@"set mypath to \"%@\" \n tell application \"Keynote\" \n open mypath \n tell slideshow %@ \n start slideshow\n end tell \n end tell\n",temp,temp];
// here is meaningless right
// temp is the variable I want to pass to applescript
NSDictionary *errorInfo = nil;
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:SlideURL];
[script executeAndReturnError:&errorInfo];
[script release];
あなたの誰かがより良い方法を知っていますか?
ありがとう