Platforms to show: All Mac Windows Linux Cross-Platform

Back to LoginItemsMBS class.

LoginItemsMBS.AddFile(file as FolderItem, hidden as boolean=false) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Adds a file to the login items.

Returns true on success.

For newer Mac OS X versions, please use LSSharedFileListMBS class instead.

LoginItemsMBS.AddURL(url as string, hidden as boolean=false) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Adds an url to the item list.

Returns true on success.

For newer Mac OS X versions, please use LSSharedFileListMBS class instead.

LoginItemsMBS.DisplayName(index as Integer) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.4 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The display name of the item with the given index.
Example
dim l as LoginItemsMBS

l=new LoginItemsMBS
MsgBox l.displayName(0) // shows name of first item

The display name may be localized.

LoginItemsMBS.File(index as Integer) as FolderItem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The file reference of the item with the given index.

Index is from 0 to count-1.

LoginItemsMBS.IsHidden(index as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Whether the item with the given index should be hidden after launch.

Index is from 0 to count-1.

This value does not work in Mac OS X 10.4, but works in 10.5.

LoginItemsMBS.Name(index as Integer) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.4 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The name of the item with the given index.
Example
dim l as LoginItemsMBS

l=new LoginItemsMBS
MsgBox l.Name(0) // shows name of first item

This is the file name. To get the name for display, use displayname.

LoginItemsMBS.OldAddLoginItem(file as folderitem,hide as boolean,allusers as boolean) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.5 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Adds a file to the loginitems list.
Example
dim f as folderItem
dim r as new LoginItemsMBS

f=app.applicationFileMBS
if r.OldAddLoginItem(f,false,false) then
msgBox f.displayName+" has been added to the login items!"
else
msgBox "Something went wrong."
end if

This is the old method which edits the preferences file directly.
Do not use it unless you really need to. The new functions in this class handle login items using a system service and will be safer for future releases of Mac OS X.

hide matches the checkbox in the loginitems list.
allusers decides whether to set it for all user or the current one.

This function will add a LoginItem to the list of LoginItems when called. The properties given to the new LoginItem are passed when calling the function. Note that *no* check is made when adding the LoginItem to ensure that the path points to a valid application. Note that the LoginItem Is always added to the *end* of the list of LoginItems.

First Parameter (appfile):
The absolute path of the application to be launched expressed as a Xojo folderitem.

Second Parameter (hide):
A value representing if you want your application to be hidden at login time. True if you want the application to be hidden after it is launched. If you want the application to show up normally use be hidden use false.

Third Parameter (allusers):
A constant which represents which users preferences we want to change. In this case there are two alternatives: False which changes the preferences of the current user. The second alternative is True.
The kAllUsers LoginItems are launched for all users on the system. You must be root or admin to use the kAllUsers option.

Function Returns:
This function returns a boolean value representing if the function was successful.
The function returns true if the LoginItem was successfully added. False if otherwise. No additional error codes are returned.

Other Notes:
This code doesn't work properly if more than one application is attempting to write to the LoginItems preference at once.
Also no check is made to ensure that what you are adding to the LoginItem list isn't a duplicate. If there is a duplicate however only one instance of the application is launched.

LoginItemsMBS.OldCountOfLoginItems(allusers as boolean) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.5 ✅ Yes ❌ No ❌ No ❌ No Desktop only
This function will return the number of LoginItems for the user requested.
Example
// Add this code for syncronization:

dim cf as CFPreferencesMBS
dim b as Boolean

cf=new CFPreferencesMBS
b=cf.AppSynchronize(cf.kCFPreferencesCurrentApplication)

// Count items

dim r as new LoginItemsMBS
msgbox str(r.OldCountOfLoginItems(false))

This is the old method which edits the preferences file directly.
Do not use it unless you really need to. The new functions in this class handle login items using a system service and will be safer for future releases of Mac OS X.

This function returns the number of LoginItems for the user requested as a signed integer.

LoginItemsMBS.OldLoginItemPropertyAtIndex(what as Integer, index as Integer, allusers as boolean) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.5 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns a property from the loginitems list.
Example
dim i as Integer
dim c as Integer
dim l as Integer
dim path,name,hide as string
dim r as new LoginItemsMBS

c=r.OldCountOfLoginItems(false)

MsgBox str(c)+" Login items found for this user."

c=c-1
for i=0 to c
name=r.OldLoginItemPropertyAtIndex(2,i,false)
hide=r.OldLoginItemPropertyAtIndex(3,i,false)
path=r.OldLoginItemPropertyAtIndex(1,i,false)

list.addrow name
l=list.lastIndex
list.cell(l,1)=hide
list.cell(l,2)=path
list.cell(l,3)=str(i)
next

This is the old method which edits the preferences file directly.
Do not use it unless you really need to. The new functions in this class handle login items using a system service and will be safer for future releases of Mac OS X.

Index is from 0 to count-1.
What can be 1 for the absolute path of the LoginItem, 2 for the LoginItem name or 3 for a string with "false" or "true" for the hiding option.

Returns "" on any error.

LoginItemsMBS.OldRemoveLoginItem(file as folderitem,allusers as boolean) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.5 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes a file to the loginitems list.
Example
dim f as folderItem
dim r as new LoginItemsMBS

f=app.applicationFileMBS
if r.OldRemoveLoginItem(f,false) then
msgBox f.displayName+" has been added to the login items!"
else
msgBox "Something went wrong."
end if

This is the old method which edits the preferences file directly.
Do not use it unless you really need to. The new functions in this class handle login items using a system service and will be safer for future releases of Mac OS X.

The items are compared by path.
Returns true if item was found and the new list is written correctly to disk.
allusers decides whether to set it for all user or the current one.

LoginItemsMBS.OldRemoveLoginItemAtIndex(index as Integer, allusers as boolean) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.5 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes an entry from the loginitem list.

This is the old method which edits the preferences file directly.
Do not use it unless you really need to. The new functions in this class handle login items using a system service and will be safer for future releases of Mac OS X.

Index is from 0 to count-1.

LoginItemsMBS.Remove(index as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes the item from the login items list.

Index is from 0 to count-1.
The count property is updated.

LoginItemsMBS.RemoveFile(file as FolderItem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes the items matching this file reference from the list.

Returns true on success.
Count is updated.

LoginItemsMBS.RemoveURL(url as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes the item matching the given URL.

Returns true on success.

LoginItemsMBS.Update

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Reloads the list of items.

Update is done after each modification method and in the constructor.
You should never need to call this method.

LoginItemsMBS.URL(index as Integer) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Login Items MBS MacOSX Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The URL of the item with the given index.

Index is from 0 to count-1.

The items on this page are in the following plugins: MBS MacOSX Plugin.


The biggest plugin in space...