Re: Add to startup items
Re: Add to startup items
- Subject: Re: Add to startup items
- From: Bill White <email@hidden>
- Date: Thu, 20 May 2004 08:01:23 -0400
On 5/20/04 4:47 AM, Thomas C. <email@hidden> wrote:
>
I'd like to know if this is possible from AS to add and remove applications to
>
/ from startup items of the logged account. I would also need a security to
>
avoid adding an application that is already in the startup items
To remove items you could do something like this:
---------- BEGIN SCRIPT ----------
tell application "System Events"
set loginItems to name of every login item
set appName to item 1 of (choose from list loginItems with prompt
"Remove what?")
delete (every login item whose name is appName)
end tell
----------- END SCRIPT -----------
To add items, I use the following droplet:
---------- BEGIN SCRIPT ----------
on run
set theApp to choose file of type {"APPL"}
my addtologin(theApp)
end run
on open theFiles
repeat with theApp in theFiles
tell application "Finder"
if kind of theApp is not folder then my addtologin(theApp)
end tell
end repeat
end open
on trimName(thisApp) -- gets rid of .app extension
set AppleScript's text item delimiters to ".app"
set trimmedAppName to text item 1 of thisApp
set AppleScript's text item delimiters to ""
return trimmedAppName
end trimName
on addtologin(thisApp) -- adds an item to login items
set appPath to POSIX path of thisApp
tell application "System Events"
set appName to name of thisApp
set shortName to my trimName(appName)
if shortName is not in (name of every login item) then
make login item at end with properties {path:appPath}
end if
end tell
end addtologin
----------- END SCRIPT -----------
Hope that helps,
Bill
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.