Jump to content
Welcome to InsanelyMac Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Allan

      Forum Rules   04/13/2018

      Hello folks! As some things are being fixed, we'll keep you updated. Per hour the Forum Rules don't have a dedicated "Tab", so here is the place that we have our Rules back. New Users Lounge > [READ] - InsanelyMac Forum Rules - The InsanelyMac Staff Team. 
Sign in to follow this  
geocool

Script Doesn't Close (Needs Force Quit)

1 post in this topic

Recommended Posts

Hello !

 

I created my first script, i saved it as application and I run it but i can't close it !

 

Here is the script:

-- iTunes Variables --
global lastSong
global trackAlbum
global trackArtist
set lastSong to ""
set trackAlbum to ""
set trackArtist to ""
set songChanged to false

-- Growl Variables --
global AppName
set AppName to "iTunes Notify"
set NotificationList to {"Playing Track"}
set EnableNotification to {"Playing Track"}

-- Functions --
--Check if application is running --
on appIsRunning(AppName)
tell application "System Events" to set appNameIsRunning to exists (processes where name is AppName)
return appNameIsRunning
end appIsRunning
-- notify user -- 
on notifyUser()
set info to trackArtist & "
" & trackAlbum

tell application "Growl"
	notify with name "Playing Track" title lastSong description info application name AppName
end tell

end notifyUser

-- Register To Growl
if appIsRunning("Growl") then
tell application "Growl"
	register as application AppName all notifications NotificationList default notifications EnableNotification icon of application "iTunes"
end tell
else
display dialog "Error Please Run Growl"
end if

-- ---------------------------- Main Application -------------------------------- --
-- Get First Song Played
if appIsRunning("iTunes") then
-- Wait Until track is played
tell application "iTunes"
	repeat
		delay 1
		if player state is playing then
			exit repeat
		end if
	end repeat
	-- Take Last Song
	set lastSong to name of current track
end tell
end if

-- Check if song changed 
repeat
delay 1
if appIsRunning("iTunes") then
	tell application "iTunes"
		if player state is playing then
			if lastSong is not name of current track then
				set songChanged to true
				set lastSong to name of current track
				set trackAlbum to album of current track
				set trackArtist to artist of current track
			end if
		end if
	end tell
	-- Display Notification
	if songChanged is true then
		set songChanged to false
		notifyUser() --display dialog lastSong
	end if
end if
end repeat

 

What do i have to do to force it close on the close event ???

Thanks in advance :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.



×