CupTools
V2EX  ›  问与答

有谁也用AppleScript的?

  •  
  •   CupTools · Feb 27, 2011 · 4290 views
    This topic created in 5599 days ago, the information mentioned may be changed or developed.
    突然想获取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 ""

    真的很爽很爽.....
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   853 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:54 · PVG 05:54 · LAX 14:54 · JFK 17:54
    ♥ Do have faith in what you're doing.