I am using this script to get the value of my check box, but when I check system preferences, I don’t have a login item.
on getBoxStates_(sender)
if (my loginBox) as boolean = true then
tell application "System Events"
make new login item at end of login items with properties {path:(path to me), hidden:false}
end tell
else if (my loginBox) as boolean = false then
tell application "System Events"
if login item "ScreenTunes" exists then delete login item "ScreenTunes"
end tell
end
end getBoxStates_
Thanks! I tried it with my other check boxes and they worked but this box still doesn’t create the login item. Also, is there a way to set the checkbox to true but only on the first time the user runs the app?
I am getting 5 errors in LoginItem2.m and 1 warning in LoginItem.m. Most of the errors in LoginItem2 are semantic issue saying that LoginItem is an unknown receiver. The warning in LoginItem.m says that status is an unused variable in this line of code :
You can also do it very much like your first post (with the fix for using the box’s state) by changing the way you get your app’s path. I’m not sure why (path to me) doesn’t work (did you get an error message about that?), but this method gets the correct path and creates the new login item:
set mb to current application's NSBundle's mainBundle()
set myPath to mb's executablePath() as text
tell application "System Events"
make new login item at end of login items with properties {path:myPath, hidden:false}
end tell