LoginSignup
0
0

More than 5 years have passed since last update.

iTunesで再生した曲をtweetするAppleScript

Last updated at Posted at 2016-09-12

iTunesで再生した曲をtweetする

と思ったけど、よく考えたら通知センターに表示された内容はtweetされちゃうな……

10.9上でTwitter Scripterを利用してます。


on idle {}
    main()
    return 4
end idle

on main()
    set {aTitle, Artist_Album} to my getNotfication()
    my tweet(aTitle, Artist_Album)
end main

on tweet(aTitle, Artist_Album)
    tell application "Twitter Scripter"
        tweet aTitle & "\n" & Artist_Album using account "Twitter Accounts"
    end tell
end tweet

on getNotfication()
    tell application "System Events"
        tell process "通知センター"

            set notificationWindow to window 1 whose subrole is "AXNotificationCenterAlert" or subrole is "AXNotificationCenterBanner"

            tell scroll area 1 of notificationWindow
                --曲名
                set aTitle to the value of static text 1
                --アーティスト — アルバム
                set Artist_Album to the value of static text 2
            end tell
            return {aTitle, Artist_Album}
        end tell
    end tell
end getNotfication

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0