#title=iTunes #tooltip=iTunesを制御します #icon=C:\Program Files\iTunes\iTunes.exe iTunes = new ActiveXObject("iTunes.Application"); if (!iTunes) { alert("iTunesが用意できませんでした。"); Quit(); } function ShowMenu(menuDef) { function Array2Menu(a, commands) { var menu = CreatePopupMenu(); for (var i = 0 ; i < a.length ; ++i) { if (a[i] == null) continue; if (a[i].submenu instanceof Array) { var submenu = Array2Menu(a[i].submenu, commands); menu.AddPopup(a[i].label, submenu); } else { var index = commands.length; if (index == 0) { index = 1; } if (a[i].label == "----") { menu.Add("", 0, eeMenuSeparator); } else { var flags = (a[i].checked ? eeMenuChecked : 0) | (a[i].grayed ? eeMenuGrayed : 0); menu.Add(a[i].label, index, flags); commands[index] = a[i]; } } } return menu; } var commands = []; var menu = Array2Menu(menuDef, commands); var commandIndex = menu.Track(/*eePosMouse*/); if (commandIndex > 0) { commands[commandIndex].command(); return true; } return false; } function accel(label, i) { if (i < 9) return "&"+i.toString() +" " + label; if (i == 10) return "&0 " + label; if (i < 10 + 26) return "&" + String.fromCharCode(65 + i - 10 - 1) + " " + label; return label; } function CreatePlayList() { var list = []; var t = iTunes.CurrentPlayList.Tracks; if (t.Count > 64) { list.push({label:"曲数が多すぎます", grayed:true}); return list; } for (var i = 1 ; i <= t.Count ; ++i) { item = t.ItemByPlayOrder(i); list.push({track:item, label:accel(item.Name, i), checked:(iTunes.CurrentTrack.Index == item.Index), command: function(){this.track.Play()}} ); } return list; } function CreatePlayLists(sources) { var list = []; var t = sources.Playlists; for (var i = 1 ; i <= t.Count ; ++i) { item = t.Item(i); list.push({playlist:item, label:accel(item.Name, i), command: function(){this.playlist.PlayFirstTrack()}}); } return list; } function AddSources(menuDef) { var t = iTunes.Sources; for (var i = 1 ; i <= t.Count ; ++i) { item = t.Item(i); menuDef.push({source:item, label:accel(item.Name, i), submenu : CreatePlayLists(item)}); } } var menuDef = [ iTunes.CurrentTrack ? { label : "現在の曲の情報を表示(&T) - " + iTunes.CurrentTrack.Name, command : function () { var t = iTunes.CurrentTrack; OutputBar.Visible = true; OutputBar.Clear(); OutputBar.writeln("曲名\t: " + t.Name); OutputBar.writeln("時間\t: " + t.Time); OutputBar.writeln("アーティスト\t: " + t.Artist); OutputBar.writeln("アルバム\t: " + t.Album); OutputBar.writeln("ジャンル\t: " + t.Genre); if (t.Rating) OutputBar.writeln("レーティング\t: " + t.Rating + "/100"); OutputBar.writeln("再生された回数\t: " + t.PlayedCount); OutputBar.writeln("サンプルレート\t: " + t.SampleRate + "Hz"); OutputBar.writeln("ビットレート\t: " + t.BitRate.toString() + "kbps"); OutputBar.writeln("コメント\t: " + t.Comment); } } : null, iTunes.CurrentPlayList ? ({ label : "現在のプレイリスト(&L) - " + iTunes.CurrentPlayList.Name, submenu: CreatePlayList() }) : null, (iTunes.CurrentTrack && iTunes.CurrentPlayList) ? {label:"----"} : null, { label : "再生/一時停止(&P)", grayed:false, checked: false, command : function () { iTunes.PlayPause(); } }, { label : "次の曲(&N)", grayed:false, checked: false, command : function () { iTunes.NextTrack(); } }, { label : "前の曲(&B)", grayed:false, checked: false, command : function () { iTunes.PreviousTrack(); } }, { label : "ミュート(&M)", grayed:false, checked: iTunes.Mute, command : function () { iTunes.Mute = ! iTunes.Mute; } }, iTunes.CurrentPlayList ? ({label : "----"}) : null, iTunes.CurrentPlayList ? ({ label : "シャッフル", checked:iTunes.CurrentPlayList.Shuffle, command: function() {iTunes.CurrentPlayList.Shuffle = ! iTunes.CurrentPlayList.Shuffle;} }) : null, iTunes.CurrentPlayList ? ({ label : "リピートしない", checked:(iTunes.CurrentPlayList.SongRepeat == 0), command: function() {iTunes.CurrentPlayList.SongRepeat = 0;} }) : null, iTunes.CurrentPlayList ? ({ label : "全項目リピート", checked:(iTunes.CurrentPlayList.SongRepeat == 1), command: function() {iTunes.CurrentPlayList.SongRepeat = 1;} }) : null, iTunes.CurrentPlayList ? ({ label : "1項目リピート", checked:(iTunes.CurrentPlayList.SongRepeat == 2), command: function() {iTunes.CurrentPlayList.SongRepeat = 2;} }) : null, iTunes.CurrentPlayList ? ({label : "----"}) : null, { label : "音量(&V) - "+iTunes.SoundVolume.toString() +"/100", submenu: [ {label: "1&00", checked:(100 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=100;}}, {label: "&90", checked:(90 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=90;}}, {label: "&80", checked:(80 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=80;}}, {label: "&70", checked:(70 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=70;}}, {label: "&60", checked:(60 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=60;}}, {label: "&50", checked:(50 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=50;}}, {label: "&40", checked:(40 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=40;}}, {label: "&30", checked:(30 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=30;}}, {label: "&20", checked:(20 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=20;}}, {label: "&10", checked:(10 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=10;}}, {label: "0(&Z)", checked:(0 == iTunes.SoundVolume), command:function () {iTunes.SoundVolume=0;}} ] }, {label:"----"} ]; AddSources(menuDef); var t = iTunes.CurrentTrack; if (t) { status = t.Name + " - " + t.Album + " - " + t.Artist; } ShowMenu(menuDef);