Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Some improvements' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Some improvements
Authored by: charlau on Mar 13, '10 08:29:25AM
Your script's great, thanks! I started with it, adding growl notifications. so here it is: (Took out the comments to not be repetitive here. I also took out the delay. One thing I'm not sure about is how to get the path for the grolwhelper - here it's hardcoded).
property pPathToLoginItemsFolder : "" -- The script will set this value.
set loginItemsList to {} -- The script will set this value.


tell application "Finder"
	set pPathToLoginItemsFolder to ((container of (path to me) as alias) as text) & "Login Items:"
	set loginItemsList to every alias file of folder pPathToLoginItemsFolder
end tell

repeat with i in loginItemsList
	tell application "Finder"

		set originalItem to original item of i
		if (class of originalItem is application file) then
			tell me to launch application (originalItem as string)
			if (comment of i is "hide") then
				set visible of process ((displayed name of originalItem) as text) to false
			end if
			open originalItem
			if (comment of i is "hide") then
				set appName to  
				(displayed name of application file id (creator type of originalItem)) as text

				set visible of process appName to false
			end if
		end if
	end tell
	set justAppName to getAppName(originalItem as string)
	tell application "GrowlHelperApp"
		notify with name 
			"Program started" title 
			"The following program launched" description justAppName 
			application name 
			"Custom login items" icon of application justAppName
	end tell
end repeat

on setupGrowl()
	tell application "System Events"
		set isRunning to 
			(count of (every process whose name is "GrowlHelperApp")) > 0
	end tell
	if (isRunning = 0) then
		open application  
		delay 2
	end if
	tell application "GrowlHelperApp"

		set the allNotificationsList to {"Program started"}
		set the enabledNotificationsList to {"Program started"}
		register as application 
			"Custom login items" all notifications allNotificationsList 
			default notifications enabledNotificationsList 
			icon of application "Script Editor"
	end tell
end setupGrowl

on getAppName(thePath)
	set oldDelims to AppleScript's text item delimiters
		set AppleScript's text item delimiters to {":"}
		set withExt to the last text item in (thePath as string) as string
		set AppleScript's text item delimiters to {"."}
		set withoutExt to the first text item in withExt as string
		set AppleScript's text item delimiters to oldDelims
		return withoutExt
	on error
		set AppleScript's text item delimiters to oldDelims
	end try
end getAppName

[ Reply to This | # ]