' ==========
' iTunesInfo
' ==========
' Version 1.0.0.3 - April 5th 2012
' Copyright © Steve MacGuire 2011-2012
' http://samsoft.org.uk/iTunes/iTunesInfo.vbs
' Please visit http://samsoft.org.uk/iTunes/scripts.asp for updates

' =======
' Licence
' =======
' This program is free software: you can redistribute it and/or modify it under the terms
' of the GNU General Public License as published by the Free Software Foundation, either
' version 3 of the License, or (at your option) any later version.

' This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
' without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
' See the GNU General Public License for more details.

' Please visit http://www.gnu.org/licenses/gpl-3.0-standalone.html to view the GNU GPLv3 licence.

' ===========
' Description
' ===========
' Reads & displays miscellaneous information from iTunes.
' Modify to read any other data of interest that cannot be read in the iTunes interface.

' =========
' ChangeLog 
' =========
' Version 1.0.0.1 - Initial version
' Version 1.0.0.2 - Minor updates
' Version 1.0.0.3 - Add playlist counts

' ==========
' To-do List
' ==========
' Add things to do

Option Explicit
Dim Count,iTunes,nl,T,tab,Tracks
Dim I,L,Lists,FP,NP,SP
nl=vbCrLf
tab=Chr(9)
Set iTunes=CreateObject("iTunes.Application")

Set Tracks=iTunes.SelectedTracks
If Tracks is Nothing Then
  Count=0
Else 
  Count=Tracks.Count
End If

FP=0
NP=0
SP=0
' Loop through playlists
Set Lists=iTunes.Sources.Item(1).Playlists
For I=Lists.Count To 1 Step -1
  Set L=Lists.Item(I)
  If L.Kind=2 Then
    If L.SpecialKind=4 Then
      FP=FP+1
    ElseIf L.Smart Then
      SP=SP+1
    Else
      NP=NP+1
    End If
  End If
Next  

' Set values here as required
' Refer to iTunes COM SDK to see what can be controlled via script commands
' iTunes.ForceToForegroundOnDialog=False

' List out iTunes properties
T="iTunes version" & tab & tab & tab & iTunes.Version & nl
T=T & "XML location" & tab & tab & tab & iTunes.LibraryXMLPath & nl
T=T & "Selected playlist" & tab & tab & tab & iTunes.BrowserWindow.SelectedPlaylist.Name & nl
T=T & "Current source" & tab & tab & tab & iTunes.BrowserWindow.SelectedPlaylist.Source.Name & nl
T=T & "Current encoder" & tab & tab & tab & iTunes.CurrentEncoder.Name & nl
T=T & "AppCommandMessageProcessing" & tab & iTunes.AppCommandMessageProcessingEnabled & nl
T=T & "Force dialogs to foreground" & tab & tab & iTunes.ForceToForegroundOnDialog & nl
T=T & "Process media keys" & tab & tab & tab & iTunes.AppCommandMessageProcessingEnabled & nl & nl
T=T & "Total number of items in the library" & tab & iTunes.LibraryPlaylist.Tracks.Count & nl
T=T & "Regular playlists " & tab & tab & tab & NP & nl
T=T & "Smart playlists" & tab & tab & tab & SP & nl
T=T & "Playlist folders" & tab & tab & tab & FP & nl & nl
If Count=0 Then
  T=T & "There are no tracks currently selected."
ElseIf Count=1 Then
  T=T & "There is 1 track currently selected."
Else
  T=T & "There are " & Count & " tracks currently selected."
End If
MsgBox T,0,"iTunes Info"

