显示带有当前iTunes专辑封面的对话框


Answers:


1

是的。这是我想出的。很晚了,恐怕有点粗糙了...

  1. 下载Pashua-用于自定义对话框的免费工具
  2. 将应用程序复制Pashua.scpt到“应用程序”文件夹
  3. 粘贴以下代码,并根据自己的喜好进行调整。

编辑:从此答案中提取的艺术品代码。


# 
# Start of code
#
global f, a


tell application "iTunes"

    tell artwork 1 of current track
        set d to raw data
        if format is «class PNG » then
            set x to "png"
        else
            set x to "jpg"
        end if
    end tell

    set a to album of current track
end tell

set f to (((path to temporary items) as text) & "cover." & x)
set b to open for access file result with write permission
set eof b to 0
write d to b
close access b


-- Get the path to the folder containing this script
tell application "Finder"
    set appPath to (path to applications folder)
    #set thisFolder to (container of (path to me)) as string
    set thisFolder to appPath as string
    if "Pashua:Pashua.app:" exists then
        -- Looks like the Pashua disk image is mounted. Run from there.
        set customLocation to "Pashua:"
    else
        -- Search for Pashua in the standard locations
        set customLocation to ""
    end if
end tell

set customLocation to ""

log "customLocation: " & customLocation
log "f: " & f
try
    set thePath to alias (thisFolder & "Pashua.scpt")
    set pashuaBinding to load script thePath

    tell pashuaBinding
        -- Display the dialog

        try
            set pashuaLocation to getPashuaPath(customLocation)
            set dialogConfiguration to my getDialogConfiguration(f)
            set theResult to showDialog(dialogConfiguration, customLocation)

        on error errorMessage
            display alert "PashuaBinding: An error occurred" message errorMessage as warning
        end try
    end tell
on error errStr number errorNumber
    display dialog errStr
end try


-- Returns the configuration string for an example dialog
on getDialogConfiguration(pashuaLocation)

    if pashuaLocation is not "" then
        set img to "img.type = image
              img.x = 0
              img.y = 50
              img.maxwidth = 128
              img.tooltip = Album Art
              img.path = " & (POSIX path of pashuaLocation) & return
    else
        set img to ""
    end if

    return "
# Set window title
*.title = Currently playing...

# Introductory text
txt.type = text
txt.label = Track/Album Info
txt.default = Album: " & a & return & "
txt.height = 10
txt.width = 300
txt.x = 150
txt.y = 130
#txt.tooltip = This is an element of type “text”

db.type = defaultbutton
#db.tooltip = This is an element of type “defaultbutton” (which is automatically added to each window, if not included in the configuration)
" & img
end getDialogConfiguration

#
# END of CODE
#
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.