2017-09-03 9 views
1

私はある時点でiTunesフォルダのプレイリストを再生したいと思っていました。 しかし、私は後でiTunesをミニプレーヤーに切り替えたいと思っています。だからここにコードがありますスクリーンセーバーが起動している間にAppleScriptを実行する

tell application "iTunes" to quit 
delay 5 

tell application "iTunes" 
    reopen 
    activate 
    set song repeat to all 
    set shuffle enabled to true 
    set sound volume to 35 
    delay 5 
    get name of AirPlay devices 
    set selected of AirPlay device "Airport Express" to true 
    play playlist "mom's music" 
end tell 

delay 20 

-- here comes the part I don't get 

tell application "System Events" 
    tell process "iTunes" 
     set frontmost to true 
     if title of window 1 is "미니 플레이어" then 
      click menu item 9 of menu 9 of menu bar 1 
      delay 5 
      click menu item 9 of menu 9 of menu bar 1 
     else 
      click menu item 9 of menu 9 of menu bar 1 
     end if 
    end tell 
end tell 

上部を気にしないでください。 「システムイベント」で見てください。

スクリーンセーバーが実行されていないときには正常に動作しますが、スクリーンセーバーが実行されているときは表示されませんが、逃したものはわかりません。

私は認識していないスクリーンセーバーの下でAppleScriptを実行する別の制限がありますか?任意の提案をいただければ幸いです。ありがとう。


2017年9月17日

を追加私は、「ウィンドウ」メニュー項目、iTunes(メイン1)ウィンドウが消えを押したときに気づくようになりました。それは、スクリーンセーバーを超えて、ウィンドウで何かをするのは、AppleScriptで行う必要があるのだろうか?

答えて

0

スクリーンセーバーが実行中の場合でも、スクリプトは実行されますが、特定のイベントは処理されません。この問題を回避するには、UI Scriptingに依存するコードを実行する前にスクリーンセーバーを停止します。

例:

tell application "System Events" 
    key code 53 -- # Esc key. 
    delay 1 - # Adjust as necessary, the screen saver needs to have stopped before continuing. 
    tell process "iTunes" 
     set frontmost to true 
     if title of window 1 is "미니 플레이어" then 
      click menu item 9 of menu 9 of menu bar 1 
      delay 5 
      click menu item 9 of menu 9 of menu bar 1 
     else 
      click menu item 9 of menu 9 of menu bar 1 
     end if 
    end tell 
end tell 
+0

を試してみては提案をいただき、ありがとうございます。それは私のmac miniとmacbook air thoの両方で動作しませんでした。それはESCキーのためにスクリーンセーバーを停止するのに十分ではなかったことができますか?もう一度ありがとうございます:) – Canor

0

このバージョン

try 
    tell application id "com.apple.ScreenSaver.Engine" to quit 
end try 

tell application "System Events" 
    tell process "iTunes" 
     set frontmost to true 
     if title of window 1 is "미니 플레이어" then 
      click menu item 9 of menu 9 of menu bar 1 
      delay 5 
      click menu item 9 of menu 9 of menu bar 1 
     else 
      click menu item 9 of menu 9 of menu bar 1 
     end if 
    end tell 
end tell 
+0

ありがとうございますが、どちらもうまくいきませんでした... – Canor

関連する問題