2012-02-27 36 views
0

Mac版がに対応していますので、Wineを使用してMacにWarcraft3:TFTを最近インストールしました Lion。 AppleScriptを使ってワイン用のターミナルコマンドを実行してホットコーナーを無効にするスクリプトを書いたので、画面をナビゲートする際に問題はありません。AppleScriptはスクリプトとして実行されますが、アプリケーションとしては実行されません。

私はスクリプトを書いており、Applescript(コンパイル>実行)で正常に動作します。実際の問題は、スクリプトをアプリケーションとして保存しようとするときに発生します。

set settings1 to {"-", "Desktop", "Start Screen Saver", "Mission Control"} 
set settings2 to {"-", "-", "-", "-"} 

tell application "Terminal" 
    do script "/opt/local/bin/wine ~/.wine/drive_c/Program\\ Files/Warcraft\\ III/war3.exe" 
end tell 

tell application "System Preferences" 
    reveal pane id "com.apple.preference.expose" 
    activate 
    tell application "System Events" 
    tell window "Mission Control" of process "System Preferences" 
     click button "Hot Corners…" 
     tell sheet 1 
      tell group 1 
       set theSettings to settings2 
       set functionKeys to false 
       repeat with k from 1 to 4 
        set theValue to item k of theSettings 
        tell pop up button k 
         if value is not theValue then 
          click 
          click menu item theValue of menu 1 
         end if 
        end tell 
       end repeat 
      end tell 
      click button "OK" 
     end tell 
    end tell 
end tell 
quit 
end tell 

display alert "Done playing?" buttons {"Yes"} 
set response to button returned of the result 
if response is "Yes" then 
--Start return to normal settings 
tell application "System Preferences" 
    reveal pane id "com.apple.preference.expose" 
    activate 
    tell application "System Events" 
     tell window "Mission Control" of process "System Preferences" 
      click button "Hot Corners…" 
      tell sheet 1 
       tell group 1 
        set theSettings to settings1 
        set functionKeys to true 
        repeat with k from 1 to 4 
         set theValue to item k of theSettings 
         tell pop up button k 
          if value is not theValue then 
           click 
           click menu item theValue of menu 1 
          end if 
         end tell 
        end repeat 
       end tell 
       click button "OK" 
      end tell 
     end tell 
    end tell 
    quit 
end tell 
--End return to normal settings 

--quit X11 and terminal 
tell application "X11" 
    quit 
end tell 
tell application "Terminal" 
    quit 
end tell 
end if 
:スクリプト自体がされてここ

error message on script app execution

:このエラーを取得する - 私は、アプリケーションとして保存してから(「フローズン・スローンウォークラフトIII」という名前の)アプリケーションを実行しよう

これは私がApplescriptで実際に書いた初めてのことなので、私が見ていない何らかのエラーがあるかもしれません。アドバイスやご意見をお寄せいただきありがとうございます!

答えて

1

あなたのエラーコードはAppleScriptと直接関係ありません。エラー-10810は、Launch Servicesのエラーコードで、一般的な、つまり不明なエラーを通知します。 OS Xのプロセステーブルが実行されると、かなり頻繁にスローされるようです。 background post on the issue at the X Labsは非常に徹底しており、問題の診断(および場合によっては是正)のためのステップバイステップの手順が記載されています。

OTノートでは、GUIスクリプトを使用してホットコーナーをオンまたはオフに切り替えることがわかりました。これは不要です:ライオンのシステムイベント缶スクリプトあなたのGUIスクリプトでワームの缶を惜しみその公開プリファレンススイート、すなわち

property hotCornerSettings : {} 

to disableHotCorners() 
    set hotCorners to {} 
    tell application "System Events" 
     tell expose preferences 
      set end of hotCorners to a reference to bottom left screen corner 
      set end of hotCorners to a reference to top left screen corner 
      set end of hotCorners to a reference to top right screen corner 
      set end of hotCorners to a reference to bottom right screen corner 
      repeat with hotCorner in hotCorners 
       set hotCornerProps to properties of hotCorner 
       set end of hotCornerSettings to {hotCorner, {activity:activity of hotCornerProps, modifiers:modifiers of hotCornerProps}} 
       set properties of hotCorner to {activity:none, modifiers:{}} 
      end repeat 
     end tell 
    end tell 
end disableHotCorners 

to restoreHotCorners() 
    tell application "System Events" 
     tell expose preferences 
      repeat with settings in hotCornerSettings 
       set properties of item 1 of settings to item 2 of settings 
      end repeat 
     end tell 
    end tell 
end restoreHotCorners 

...を経由して、これらの設定。

+0

レスポンスとライオンの公開情報に感謝します。私はちょっと混乱していますが、設定のいずれかがどこにでも保存されているとは思われません。正しい設定を復元しているかどうかはどのようにわかりますか? AppleScript:/ – wchristiansen

+0

@Floofer:AppleScriptプロパティの設定を最初の行に保存しています。プロパティは、スクリプトの実行後に保持されます(スクリプトが再コンパイルされたときにのみ再初期化されます)。 [Apple Script Language Guide](https://developer.apple.com/library/mac/#documentation/AppleScript/Conceptual/AppleScriptLangGuide/conceptual/ASLR_variables.html#//apple_ref/doc/uid/TP40000983-CH223-SW10) )は、プロパティとそのスコープに関するすべての細部の細部を持っています。 – kopischke

+0

@Floofer:ああ...ちょうどあなたの問題があります(別のコメントを追加して申し訳ありません.5分の編集ウィンドウが経過しました):スクリプトはあなたの現在の設定を上記のプロパティに保存します。つまり、これらをスクリプトにハードコードする必要はなく、スクリプトは常に見つかった状態に復元されます。 注意ハンドラのみを提供しました。 'do shell script'行と、提供された2つのハンドラへの呼び出しとquitコマンドを追加する必要があります(これは、一言で言えば'アプリケーションに通知して終了する 'X11)。 – kopischke

関連する問題