2

これは私が持っている AppleScript です。Minecraft を開いて自動ログインするためのものです。アプリケーションにバンドルされていない場合は問題なく動作します。ただし、バンドルするたびに、最後に開いたままになり、「[スクリプト] の終わりがスクリプトの終わりを理解していません」というエラーが表示されます。私は何を間違っていますか?

if application "Minecraft" is running then
    beep 1
    display dialog "Error: Minecraft cannot be launched as it is already running." buttons {"Cancel"} default button 1
end if
tell application "Minecraft"
    launch
    activate
end tell
set timeoutSeconds to 1
set uiScript to "click Ul Element \"Login\" of window \"Minecraft Launcher\" of application process \"Minecraft\""
my doWithnmeout(uiScript, tlmeoutSeconds)
end run
on doWithnmeout(uiScript, tlmeoutSeconds)
    set endDate to (current date) + timeoutSeconds
    repeat
        try
            run script " tell application \"System Events\"
" & uiScript & "
end tell"
            exit repeat
        end try
    end repeat
end doWithnmeout
end run
tell application "Minecraft"
    activate
end tell
end run
4

2 に答える 2

1

「end run」を含む行を削除します。通常、applescript を実行すると、次のように構成された「実行時」ハンドラでコードが実行されます...

on run
   -- your code goes here
end run

-- any handlers go here like your doWithTimeout() handler

ただし、on run ハンドラを省略すると、applescript はすべてが on run ハンドラ内にあると想定します。したがって、「終了時」のように使用したい特定の AppleScript ハンドラーが他にない限り、実際には必要ありません。

ただし、「on run」ステートメントなしで「end run」を使用したり、「end run」を複数回使用したりしないでください。

于 2013-01-30T16:34:04.973 に答える