我正在尝试使用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文件格式有相同的结果。 SaveArtworkToFile返回的strResult为空。 AHK iTunes.Application COM对象是否应支持此方法?
谢谢,新年快乐!
答案 0 :(得分:1)
Parameters: filePath Full path to the artwork image file.
我错过了“完整”这个词。在我的剧本中,我依靠相对路径。我刚用绝对路径和这项工作测试过它!
答案 1 :(得分:0)
用Google搜索:IITArtwork::SaveArtworkToFile
HRESULT IITArtwork :: SaveArtworkToFile([in] BSTR filePath)
将图稿数据保存到图像文件中。保存数据的格式由图稿的格式指定 (JPEG,PNG或BMP)。必须已包含该文件的目录 存在,它不会被创建。如果该文件已存在,则为 内容将被替换。
参数:filePath图稿图像文件的完整路径。
该方法不会返回值(正如汉斯在评论中所说)。尝试:
objArtwork.SaveArtworkToFile(strFilePath . "." . strExtension)