0

无法弄清楚这个循环-我希望仅在 myText 更改(即个人正在收听的专辑更改)时重复以下函数-我已经能够使其循环一定次数或在曲目事件中重复更改,但我希望它在专辑更改时重复。

tell application "iTunes"
repeat if myText changes
if player state is playing then
    set albumName to (get album of current track)
    set myText to text 1 thru 10 of albumName
end if
end repeat
end tell

open location "http://bandsite.com/shows/" & myText

当代码在没有重复命令的情况下工作时,它看起来像这样:

tell application "iTunes"
if player state is playing then
set albumName to (get album of current track)
set myText to text 1 thru 10 of albumName
end if
end tell

open location "http://bandsite.com/shows/" & myText 

如果 myText 发生变化,我需要重复整个函数

4

2 回答 2

0
temptext = mytext
do
   if temptext != myText

      tell application "iTunes"
      if player state is playing then
      set albumName to (get album of current track)
      set myText to text 1 thru 10 of albumName
      end if
      end tell

     temptext = myText

   end if

while temptext==text

试试这个

希望这是你想要的...

于 2013-03-13T12:57:47.047 回答
0

将此保存为保持打开的应用程序:

property myList : {}

on run
    set albumA to my playCheck()
    if albumA ≠ false then
        set end of myList to albumA
    else
        quit -- Quit on the next idle.
        return 1 -- Please send the next idle as soon as possible.
    end if
end run

on idle
    set albumA to my playCheck()
    if albumA ≠ false then
        set end of myList to albumA
        if (item -1 of myList) ≠ (item -2 of myList) then
            open location "http://bandsite.com/shows/" & (text 1 thru 10 of albumA)
        end if
    end if
    return 3
end idle

on playCheck()
    tell application "iTunes"
        if player state is playing then return (get album of current track)
        return false
    end tell
end playCheck
于 2013-03-13T14:14:58.307 回答