Why does iTunes launch?

I made this script to work with ‘ScriptSaver’ in order to launch the iTunes visualizer ONLY if iTunes is already launched and playing.
I inserted an “if” statement to check if iTunes is already active, but this script launches iTunes anyway. Why?
Is there a way to NOT have iTunes launch if it isn’t already launched?
here’s the script…


property theModule : "ElectricSheep"

tell application "System Events"
	set allAppList to name of (application processes) as string
	--set front_app to name of (item 1 of (get processes whose frontmost = true)) as string
end tell

if "iTunes" is in allAppList then
	tell application "iTunes"
		if player state is playing then
			set full screen to true
			set visuals enabled to true
			
			tell application "ScreenSaverEngine"
				quit
			end tell
		end if
		if player state is not playing then
			do shell script "/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -module \"" & theModule & "\""
		end if
		
	end tell
end if

Browser: Firefox 2.0.0.8
Operating System: Mac OS X (10.3.9)

Hi,

the problem is your (useless) string coercion in the line

set allAppList to name of (application processes) as string

the process iTunesHelper is active, even if iTunes is not running,
and your comparison detects iTunesHelper and the condition is true

Omit as string then it works.

I would prefer

property theModule : "ElectricSheep"

tell application "System Events" to set iTunesRuns to "iTunes" is in (get name of processes)

if iTunesRuns then
.

Thanks for your help.
I’m learning- slowly but surely.
I love this site.