りんごの備忘録

へなちょこポカ大生のへなちょこブログ

AppleScriptで曲の変わり目に通知が来るようにするまで

音楽好きの猛者ならいつ何時でも曲の情報を知りたいはずでしょう(適当)しかしそのためだけに通知センターを開くのはよろしくない.それならば曲の変わり目に通知を入れれば一瞬で曲名,アルバム名をみることができるのではないか!早速作ってみた.

property theName : ""
tell application "iTunes"
	if theName is "" then set theName to name of current track
end tell

on idle
	tell application "iTunes"
		try
			set tmpName to name of current track
		on error
			set tmpName to theName
		end try
		if tmpName is not theName then
			
			display notification "Album Name :" & album of current track with title "Album Artist :" & album artist of current track subtitle "Track Name :" & name of current track
			set theName to tmpName
			return 1
		end if
	end tell
end idle
使い方
  1. 適当な名前を付け,保存形式をアプリケーション,”ハンドラの実行後に終了しない”にチェックをつける
  2. 後はiTunesで音楽をかけたあと,先ほど保存したアプリケーションを起動する.

f:id:rinringo429:20160928023423p:plain