Applescript 如果变量更改,是否重复函数?

Applescript 如果变量更改,是否重复函数?,applescript,itunes,Applescript,Itunes,我很难理解这个循环-我希望下面的函数仅在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

我很难理解这个循环-我希望下面的函数仅在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
当代码在不使用repeat命令的情况下工作时,它如下所示:

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发生更改时重复

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
试试这个


希望这就是您想要的…

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

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

所有这些语法都不起作用,我尝试对其进行扩充,使其适合我需要它做的事情,但仍然不走运[br]
Set-tentext=myText如果tentext不是myText,则告诉应用程序“iTunes”如果播放器状态正在播放,则将albumName设置为(获取当前曲目的唱片集)如果end tell TELTEXT=myText end if open location,则将myText设置为albumName end的文本1到10http://bandsite.com/shows/“&myText repeat while testext=text end repeat
我收到一个语法错误,说“行尾不能跟在这个标识符后面。”噢。。。对不起,我不知道这是什么语言。。我以为这是一种伪语言。。试着遵循逻辑!很抱歉给您带来不便。我想我真的很接近,我只是不明白这个愚蠢的循环仍然不起作用。我已经更新了我的代码,所以应用程序一直在运行,现在当相册运行时网站地址必须更改
如果应用程序“iTunes”未运行,则返回告诉应用程序“iTunes”,如果播放器状态正在播放,则将albumName设置为(获取当前曲目的相册)将myText设置为albumName的文本1到文本10如果end tell TestExt=myText open location,将TestExt设置为myText endhttp://bandsite.com/shows/“&myText repeat while TELTEXT=myText的文本如果TELTEXT不是myText,则打开位置”http://bandsite.com/show"&myText end if end repeat
是否尝试将我在回答中发布的脚本保存为“保持打开”应用程序?是-当我将其保存为“保持打开”应用程序时,它根本不起作用。当我在apple脚本编辑器中运行它时,它只返回相册的日期(前10个整数),但不打开网站。我需要它来打开一个网站,然后在专辑更改时更改网站地址。我假设你在播放歌曲时打开了应用程序?如果没有,脚本会自动退出。你能详细说明一下“什么都没发生”吗?应用程序是否启动、退出、停留在dock中?我还可以假设,在你播放一首歌曲后,你将歌曲更改为另一张专辑中的歌曲吗?