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



Sign In
Create Account








