有谁也用AppleScript的?

2011-02-27 16:06:21 +08:00
 CupTools
突然想获取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 ""

真的很爽很爽.....
3679 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/9039

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX