2012-01-19 6 views
0

次のスクリプトを実行している:アップルスクリプトの構文エラー

on run 
    tell application "Safari" 
    set allWins to every window 
    set allTabs to {} 
    repeat with currWin in allWins 
     set allTabs to allTabs & every tab of currWin 
    end repeat 
    repeat with currTab in allTabs 
     try 
     if ((characters -10 thru -1 of (title of currTab as string)) as string) = "Google Music" then set musicTab to currTab 
     end try 
    end repeat 
    tell musicTab 
     execute javascript "SJBpost(\"playPause\");" 
    end tell 
    end tell 
end run 

受信はExpected end of line but found identifier.javascriptが強調表示構文エラーです。

私はオートメーターを使用しており、thisの記事に続いてGoogle音楽のホットキーを作成しようとしています。

答えて

2

あなたは少しより密接linked articleを読むことをお勧めします:「Safariの」

Safariを使用している場合は、への最初の行に「Google Chromeを」変更の近くに(単語のタイトルを変更中央に)名前をつけて、3行目から最後の行に実行という単語を変更します。したがって

交換してください:

tell musicTab 
    execute javascript "SJBpost(\"playPause\");" 

で:

tell musicTab to do javascript "SJBpost('playPause');" 

また、その段落change the word title (near the middle) to nameの2番目の命令に従っていません。すべてのこれらの変更によって、それは次のようになります。

on run 
    tell application "Safari" 
        ^^^^^^ 
    set allWins to every window 
    set allTabs to {} 
    repeat with currWin in allWins 
     set allTabs to allTabs & every tab of currWin 
    end repeat 
    repeat with currTab in allTabs 
     try 
     if ((characters -12 thru -1 of (name of currTab as string)) as string) = "Google Music" then set musicTab to currTab 
         ^^^    ^^^^          ^^^^^^^^^^^^ 
     end try 
    end repeat 
    tell musicTab to do javascript "SJBpost('playPause');" 
        ^^ 
    end tell 
end run 

^^^文字マーカーを含む3つの行を削除し、彼らはそれをできるだけ明らかにするためにちょうどそこにいます。

Kurt Rudolphによれば、Google Music(ベータ版ではない)と呼ばれるようになったので、タブのタイトルの検出も変更しました。

私が見るすべてがあるので、あなたは、残念ながら、この自分自身をテストする必要があります:

RIAAはあまりトラブル

:-)裁判所に私をドラッグを持っているでしょう。おそらく
We're sorry. Google Music is currently only available in the United States