这是一个创建于 5001 天前的主题,其中的信息可能已经有所发展或是发生改变。
突然想获取iTunes的Now Playing,然后就找了下资料,结果发现,AppleScript是非常好用的
获取Now Playing:
try
tell application "Finder"
if (get name of every process) does not contain "iTunes" then
set output to "iTunes is not active"
else
tell application "iTunes"
if player state is not playing then
set output to "iTunes is not playing"
else
set art to artist of current track as string
set tra to name of current track as string
set alb to album of current track as string
set output to tra & " [" & alb & "] by " & art
end if
end tell
end if
end tell
on error
set output to "An unexpected error has occurred"
end try
使用Growl提醒:
set AppName to "AppleScript Growl"
set NotifyName to "Everything"
on doRegister() --YOU NEED TO REGISTER FIRST!
global AppName, NotifyName
tell application "GrowlHelperApp"
set the enabledNotificationsList to {NotifyName}
register as application AppName all notifications enabledNotificationsList default notifications enabledNotificationsList
end tell
end doRegister
on doNotify(title, desc)
global AppName, NotifyName
set titleToNotify to title
set descToNotify to desc
tell application "GrowlHelperApp"
notify application name AppName with name NotifyName title titleToNotify description descToNotify
end tell
end doNotify
on doNotifyWithIcon(title, desc, useapp)
global AppName, NotifyName
set titleToNotify to title
set descToNotify to desc
set iconToNotify to useapp
tell application "GrowlHelperApp"
notify application name AppName with name NotifyName title titleToNotify description descToNotify icon of application iconToNotify
end tell
end doNotifyWithIcon
set output to ""
真的很爽很爽.....