我正在尝试使用AutoHotkey(v1.1)从iTunes MP3文件中提取艺术品文件。该脚本在到达 SaveArtworkToFile 方法之前运行良好。
objITunesApp := ComObjCreate("iTunes.Application")
objLibrary := objITunesApp.Sources.Item(1)
objPlaylist := objLibrary.Playlists.ItemByName("! iTunesCovers")
objTracks := objPlaylist.Tracks
Loop, % objTracks.Count
{
objTrack := objTracks.Item(A_Index)
Loop, % objTrack.Artwork.Count
{
objArtwork := objTrack.Artwork.Item(A_Index)
TrayTip, % "Track Index: " . objTrack.index
, % "Artwork: " . A_Index . "/" . objTrack.Artwork.Count . "`n"
. "Format: " . objArtwork.Format . "`n"
. "IsDownloadedArtwork: " . objArtwork.IsDownloadedArtwork . "`n"
. "Description: " . objArtwork.Description
strFilePath := objTrack.index . "-" . A_Index
if (objArtwork.Format = 1)
strExtension := "bmp"
else if (objArtwork.Format = 2)
strExtension := "jpg"
else if (objArtwork.Format = 4)
strExtension := "gif"
else if (objArtwork.Format = 5)
strExtension := "png"
else
strExtension := ""
strResult := objArtwork.SaveArtworkToFile(strFilePath . "." . strExtension)
MsgBox, % strFilePath . "." . strExtension . "`nResult: " . strResult
}
}
我收到此错误消息:
---------------------------
SaveArtworkToFile.ahk
---------------------------
Error: 0x8000FFFF - Défaillance irrémédiable
Source: (null)
Description: (null)
HelpFile: (null)
HelpContext: 0
Specifically: SaveArtworkToFile
Line#
---> 017: strResult := objArtwork.SaveArtworkToFile(strFilePath)
---------------------------
我对 bpm 和 jpg 文件格式有相同的结果。保存艺术品到文件返回的strResult为空。AHK iTunes.Application COM 对象是否应该支持此方法?
谢谢,新年快乐!
@Manuell: 哦!感谢您将文档放回我的注意。在
Parameters: filePath Full path to the artwork image file.
我错过了"满"这个词。在我的脚本中,我依赖于相对路径。我刚刚用绝对路径和这项工作对其进行了测试!
谷歌搜索它: IITArtwork::SaveArtworkToFile
HRESULT IITArtwork::SaveArtworkToFile ( [in] BSTR filePath )
将图稿数据保存到图像文件。保存数据的格式由图稿的格式指定 (JPEG、PNG 或 BMP)。包含该文件的目录必须已经 存在,它不会被创建。如果文件已存在,则其 内容将被替换。
参数:文件路径图稿图像文件的完整路径。
该方法不返回值(正如 Hans 在评论中所说)。尝试:
objArtwork.SaveArtworkToFile(strFilePath . "." . strExtension)