【问题标题】:Append a variable to a link in AppleScript?将变量附加到 AppleScript 中的链接?
【发布时间】:2013-03-12 15:36:17
【问题描述】:

目前我有这个工作代码:

on run
set info to ""
tell application "System Events"
    set num to count (every process whose name is "iTunes")
end tell
if num > 0 then
    tell application "iTunes"
        if player state is playing then
            set albumName to (get album of current track)
        end if
    end tell
end if
return text 1 thru 10 of albumName
end run

如果运行 iTunes 并且现场专辑的格式正确 (YYYY-MM-DD) - 这将恢复现场专辑的日期。我现在想获取“返回文本 1 到 10 of albumName”的结果并将其添加到此代码中:

tell application "Firefox" to activate
tell application "Firefox"
open location "http://someband.com/showID=" &  *[insert code for "text 1 thr 10 of albumName" variable]*
end tell

我知道“&”不正确,但我认为这是开始。这应该起作用的方式是,如果我正在收听“2013-03-12 Live on StackOverflow”,我希望脚本采用“2013-03-12”并将其附加到我的链接,以便 Firefox 打开网站地址:“@987654321 @"

...有意义吗?任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: applescript itunes


    【解决方案1】:

    试试:

    if application "iTunes" is not running then return
    
    tell application "iTunes"
        if player state is playing then
            set albumName to (get album of current track)
        end if
    end tell
    
    set myText to text 1 thru 10 of albumName
    
    -- Assuming Firefox is your default browser…
    open location "http://someband.com/showID=" & myText
    

    【讨论】:

    • 很遗憾我不能投票给你,因为我是新手,但非常感谢你的作品!有一个美好的一天,因为你做了我的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-18
    • 1970-01-01
    • 1970-01-01
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多