当我想要修改ApplScript时,我遇到了一个小问题,我正在使用它将当前的iTunes Coverin转换为我通过GeekTool在桌面上显示的图像文件。 现在我也希望调整此图像的大小,因为有些图像有点小......
我在网上找到了一些解决方案,但它们都没有... 而且由于我对AppleScript的了解不多,我自己也无法处理它。
这是我目前的代码:
set the_artwork_file to ((path to home folder) as string) & "Music:iTunes:CurrentArtwork.png"
tell application "System Events"
if ("iTunes" is in name of processes) then
tell application "iTunes"
if (player state is not stopped)
and (player state is not paused)
and (artworks of current track exists)
then
set theArt to front artwork of current track
set pic to (raw data of theArt)
try
set RefNum to (open for access the_artwork_file with write permission)
write (pic) to RefNum
close access RefNum
return
end try
end if
end tell
end if
end tell
do shell script "rm -f " & (POSIX path of the_artwork_file)
好的,没关系,我终于设法解决了。 我生成的代码基本上是正确的,但我不得不把它放到一个单独的脚本文件中。 在GeekTool中,我必须在彼此之后直接调用它们并且它工作得很好!
这是我现在使用的代码:
tell application "Image Events"
set this_image to open ((path to home folder) as string) & "Music:iTunes:CurrentArtwork.png"
scale this_image to size 1080
save this_image in ((path to home folder) as string) & "Music:iTunes:CurrentArtwork.png"
close this_image
end tell