Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSWorkspaceMBS class.

Next items

NSWorkspaceMBS.absolutePathForAppBundleWithIdentifier(bundleIdentifier as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 12.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the absolute file-system path of an application bundle.

bundleIdentifier: The bundle identifier string. This value corresponds to the value in the CFBundleIdentifier key of the application's Info.plist file. For example, the bundle identifier of the TextEdit application is com.apple.TextEdit.

Returns the file system path to the application bundle identified by bundleIdentifier, or "" if the bundle cannot be found.

NSWorkspaceMBS.activateFileViewerSelectingFiles(Files() as folderitem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Activates the Finder, and opens one or more windows selecting the specified files.
Example
dim file as FolderItem = SpecialFolder.Pictures.Child("mbs.jpg") // some file

dim w as new NSWorkspaceMBS
dim files() as FolderItem

files.Append file

// show in Finder
w.activateFileViewerSelectingFiles(files)

Available in Mac OS X v10.6 and later.

NSWorkspaceMBS.activateFileViewerSelectingURLs(URLs() as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Activates the Finder, and opens one or more windows selecting the specified files.

Available in Mac OS X v10.6 and later.

NSWorkspaceMBS.desktopImageOptionsForScreen(screen as NSScreenMBS) as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the desktop image options for the given screen.
Example
dim w as new NSWorkspaceMBS
dim m as NSScreenMBS = NSScreenMBS.mainScreen
dim dic as Dictionary = w.desktopImageOptionsForScreen(m)

break // check in debugger

screen: The screen for which to get the desktop image options.

Returns a dictionary containing key-value pairs. Keys can be NSWorkspaceDesktopImageScalingKey, NSWorkspaceDesktopImageAllowClippingKey or NSWorkspaceDesktopImageFillColorKey.
Available in Mac OS X v10.6 and later.

NSWorkspaceMBS.desktopImageURLForScreen(screen as NSScreenMBS) as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the folderitem for the desktop image for the given screen.
Example
dim w as new NSWorkspaceMBS
dim m as NSScreenMBS = NSScreenMBS.mainScreen
dim file as FolderItem = w.desktopImageURLForScreen(m)

MsgBox file.NativePath

screen: The screen for which to get the desktop image.
Returns the desktop image.
Available in Mac OS X v10.6 and later.

NSWorkspaceMBS.fileLabelColors as NSColorMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the corresponding array of file label colors for the file labels.
Example
dim w as new NSWorkspaceMBS
dim labels() as string = w.fileLabels
dim colors() as NSColorMBS = w.fileLabelColors
dim lines() as string

dim u as Integer = UBound(Colors)
for i as Integer = 0 to u
dim co as NSColorMBS = colors(i)

lines.Append labels(i)+": "+str(co.colorValue)
next

MsgBox Join(lines,EndOfLine)

This array has the same number of elements as fileLabels, and the color at a given index corresponds to the label at the same index.

You can listen for notifications named NSWorkspaceDidChangeFileLabelsNotification to be notified when file labels change which may result in changes to the order of the fileLabelColors.

Available in Mac OS X v10.6 and later.

NSWorkspaceMBS.fileLabels as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the array of file labels as strings.
Example
dim w as new NSWorkspaceMBS
dim labels() as string = w.fileLabels

MsgBox Join(labels, EndOfLine)

You can listen for notifications named NSWorkspaceDidChangeFileLabelsNotification to be notified when file labels change.
Available in Mac OS X v10.6 and later.

NSWorkspaceMBS.findApplications

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 8.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Examines all applications and updates the records of registered services and file types.
Example
NSWorkspaceMBS.findApplications

NSWorkspaceMBS.frontmostApplication as NSRunningApplicationMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Gets the frontmost application, which is the application that will receive key events.
Example
dim w as new NSWorkspaceMBS
dim n as NSRunningApplicationMBS = w.frontmostApplication

MsgBox n.localizedName

Requires Mac OS X 10.7.

NSWorkspaceMBS.fullPathForApplication(appname as string) as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 8.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the full path for the specified application.
Example
MsgBox NSWorkspaceMBS.fullPathForApplication("textedit").ShellPath
// shows /Applications/TextEdit.app

The full path for the application, or nil if the specified application was not found.

NSWorkspaceMBS.hideOtherApplications

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 8.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Hides all applications other than the sender.
Example
NSWorkspaceMBS.hideOtherApplications

The user can hide all applications except the current one by Command-Option-clicking on an application's Dock icon.

NSWorkspaceMBS.iconForFile(file as folderitem) as NSImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 8.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns an image containing the icon for the specified file.
Example
dim f as FolderItem
f=SpecialFolder.Desktop.Child("test.txt")

dim n as NSImageMBS = NSWorkspaceMBS.iconForFile(f)
n.size = new NSSizeMBS(512,512)
Backdrop=n.CopyPictureWithMask

The returned image has an initial size of 32 pixels by 32 pixels.
Returns nil on any error.

Some examples using this method:

NSWorkspaceMBS.iconForFiles(files() as folderitem) as NSImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns an image containing the icon for the specified files.
Example
dim w as new NSWorkspaceMBS
dim files() as FolderItem

dim folder as FolderItem = SpecialFolder.Pictures

// one file
files.Append folder.TrueItem(2)
canvas1.Backdrop = w.iconForFiles(files).CopyPictureWithMask

// two files
files.Append folder.TrueItem(3)
canvas2.Backdrop = w.iconForFiles(files).CopyPictureWithMask

// three files
files.Append folder.TrueItem(4)
canvas3.Backdrop = w.iconForFiles(files).CopyPictureWithMask

files: An array of folderitems, each of which contains the full path to a file.

Returns the icon associated with the group of files.

If fullPaths specifies one file, that file's icon is returned. If fullPaths specifies more than one file, an icon representing the multiple selection is returned.

NSWorkspaceMBS.iconForFileType(filetype as string) as NSImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 8.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns an image containing the icon for files of the specified type.
Example
const SizeWanted = 512
const typeWanted = "txt"

dim n as NSImageMBS = NSWorkspaceMBS.iconForFileType(typeWanted)
// set size we want
n.setSize SizeWanted*2, SizeWanted*2

// make picture
dim p as Picture = n.CopyPictureWithMask

// set DPI
p.VerticalResolution = 144
p.HorizontalResolution = 144

filetype: The file type, which may be either a filename extension or an encoded HFS file type.

The returned image has an initial size of 32 pixels by 32 pixels.
Returns nil on any error.

Running this in a thread can lead to crashes.

Some examples using this method:

NSWorkspaceMBS.isFilePackageAtPath(item as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Determines whether the specified path is a file package.
Example
dim w as new NSWorkspaceMBS
dim file as FolderItem = SpecialFolder.Applications.Child("iTunes.app")

// shows true for iTunes
MsgBox str(w.isFilePackageAtPath(file))

Returns true if the path identifies a file package; otherwise, false if the path does not exist, is not a directory, or is not a file package.

NSWorkspaceMBS.launchApplication(appname as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 8.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Launches the specified application.
Example
if NSWorkspaceMBS.launchApplication("Textedit") then
MsgBox "Ok"
else
MsgBox "failed"
end if

Returns true if the application was successfully launched or was already running; otherwise, false.

The appName parameter need not be specified with a full path and, in the case of an application wrapper, may be specified with or without the .app extension, as described in "Use of .app Extension".

See also:

NSWorkspaceMBS.launchApplication(appname as string, showicon as boolean, autolaunch as boolean) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 8.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Launches the specified application using additional options.
Example
if NSWorkspaceMBS.launchApplication("Textedit",false,false) then
MsgBox "Ok"
else
MsgBox "failed"
end if

appName: The name of the application to open.
showIcon: If false, the application's icon is not placed on the screen. (The icon still exists, though.)
autolaunch: If true, the autolaunch default is set as though the specified application were autolaunched at startup.

This method is provided to enable daemon-like applications that lack a normal user interface. Its use is not generally encouraged.
Returns true if the application is successfully launched or already running, and false if it can't be launched.

See also:

NSWorkspaceMBS.launchApplicationAtFile(file as folderitem, options as UInt32 = 0, configuration as dictionary = nil) as NSRunningApplicationMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Launches the app at the specified file location.

file: The application folderitem.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.

Returns reference to newly started application.

Available in Mac OS X v10.6 and later.

See also:

NSWorkspaceMBS.launchApplicationAtFile(file as folderitem, options as UInt32, configuration as dictionary, byref error as NSErrorMBS) as NSRunningApplicationMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Launches the app at the specified file location.
Example
dim w as new NSWorkspaceMBS
dim file as FolderItem = SpecialFolder.Applications.Child("Address Book.app")

dim error as NSErrorMBS
dim configuration as new Dictionary
dim options as Integer

// today we start 32 bit version
configuration.Value(w.NSWorkspaceLaunchConfigurationArchitecture) = w.NSBundleExecutableArchitectureI386

// and hide all others
options = w.NSWorkspaceLaunchAndHideOthers

dim r as NSRunningApplicationMBS = w.launchApplicationAtFile(file, options, configuration, error)

if r = nil then
MsgBox "Error: "+error.LocalizedDescription
else
MsgBox "Started: "+r.localizedName
end if

file: The application folderitem.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.

Returns reference to newly started application.

Available in Mac OS X v10.6 and later.

See also:

NSWorkspaceMBS.launchApplicationAtURL(URL as string, options as UInt32 = 0, configuration as dictionary = nil) as NSRunningApplicationMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Launches the app at the specified URL.

url: The application URL.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.

Returns reference to newly started application.

Available in Mac OS X v10.6 and later.

See also:

NSWorkspaceMBS.launchApplicationAtURL(URL as string, options as UInt32, configuration as dictionary, byref error as NSErrorMBS) as NSRunningApplicationMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Launches the app at the specified URL.

url: The application URL.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.

Returns reference to newly started application.

Available in Mac OS X v10.6 and later.

See also:

NSWorkspaceMBS.launchAppWithBundleIdentifier(bundleIdentifier as string, options as Integer = &h00030000, AppleEventDescriptor as Variant = nil) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 12.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Launches the application corresponding to the specified bundleIdentifier.

bundleIdentifier: A bundle identifier string. This value corresponds to the value in the CFBundleIdentifier key of the application's Info.plist file. For example, the bundle identifier of the TextEdit application is com.apple.TextEdit.
options: Options to use when launching the application. Values for this parameter are described in constants.
descriptor: Additional options specified in an AppleEvent-style descriptor. For example, you could use this parameter to specify additional documents to open when the application is launched.

Returns true if the application was found and launched; otherwise, false.

NSWorkspaceMBS.localizedDescriptionForType(typeName as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the localized description for the specified Uniform Type Identifier.
Example
MsgBox NSWorkspaceMBS.localizedDescriptionForType("public.jpeg")
// "JPEG-Bild" in German

The localized description is suitable for displaying to the user.
Available in Mac OS X v10.5 and later.

NSWorkspaceMBS.menuBarOwningApplication as NSRunningApplicationMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Gets the menu bar owning application, which is the application that currently owns and draws the menu bar.
Example
dim w as new NSWorkspaceMBS
dim n as NSRunningApplicationMBS = w.menuBarOwningApplication

MsgBox n.localizedName

Requires Mac OS X 10.7.

NSWorkspaceMBS.mountedLocalVolumePaths as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the mount points of all local volumes, not just the removable ones returned by mountedRemovableMedia.
Example
dim w as new NSWorkspaceMBS
dim paths() as string = w.mountedLocalVolumePaths

MsgBox Join(paths, EndOfLine)

Returns an array of strings, each of which contains the full pathname of the mount point for any local volumes.

NSWorkspaceMBS.mountedRemovableMedia as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the full pathnames of all currently mounted removable disks.
Example
dim w as new NSWorkspaceMBS
dim paths() as string = w.mountedRemovableMedia

MsgBox Join(paths, EndOfLine)

Returns an array of strings, each of which contains the full pathname of a mounted removable disk.

If the computer provides an interrupt or other notification when the user inserts a disk into a drive, the Finder will mount the disk immediately. However, if no notification is given, the Finder won't be aware that a disk needs to be mounted. On such systems, an application should invoke either mountNewRemovableMedia or checkForRemovableMedia before invoking mountedRemovableMedia. Either of these methods cause the Finder to poll the drives to see if a disk is present. If a disk has been inserted but not yet mounted, these methods will cause the Finder to mount it.

The Disk button in an Open or Save panel invokes mountedRemovableMedia and mountNewRemovableMedia as part of its operation, so most applications won't need to invoke these methods directly.

NSWorkspaceMBS.noteFileSystemChanged

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Informs the NSWorkspace object that the file system has changed.

The NSWorkspace object then gets the status of all the files and directories it is interested in and updates itself appropriately. This method is used by many objects that write or delete files.

The NSDocument and NSSavePanel objects use this method when saving a file. If you create a file directly, you should call noteFileSystemChanged so that the Finder can update the folder if it is open.

Available in Mac OS X v10.0 and later. Deprecated in Mac OS X v10.6.

See also:

NSWorkspaceMBS.noteFileSystemChanged(path as folderitem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Informs the NSWorkspace object that the file system changed at the specified path.

The NSWorkspace object then gets the status of all the files and directories it is interested in and updates itself appropriately. This method is used by many objects that write or delete files.

See also:

NSWorkspaceMBS.notificationCenter as NSNotificationCenterMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 9.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the notification center for workspace notifications.

NSWorkspaceMBS.NSWorkspaceActiveSpaceDidChangeNotification as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the notification names.

Posted when a Spaces change has occurred.
The notification object is the shared NSWorkspace instance. The notification does not contain a userInfo dictionary.
Available in Mac OS X v10.6 and later.

Some examples using this method:

NSWorkspaceMBS.NSWorkspaceApplicationKey as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
This constant is supplied in the userInfo dictionary of various notifications.

The value corresponding to this key is an instance of NSRunningApplication that reflects the affected application.
Available in Mac OS X v10.6 and later.

NSWorkspaceMBS.NSWorkspaceCompressOperation as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the file operation modes.

Compress file. This operation always returns an error.

NSWorkspaceMBS.NSWorkspaceCopyOperation as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the file operation modes.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test")
dim tag as Integer
dim files(-1) as string
dim b as Boolean
dim source,dest as FolderItem

// copies a file from one folder to another folder

source=f.Parent
files.Append f.name
dest=SpecialFolder.Pictures

b=NSWorkspaceMBS.performFileOperation(NSWorkspaceMBS.NSWorkspaceCopyOperation, source, dest, files, tag)

if b then
MsgBox "OK"
else
MsgBox "Failed"
end if

Copy file to destination.

NSWorkspaceMBS.NSWorkspaceDecompressOperation as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the file operation modes.

Decompress file. This operation always returns an error.

NSWorkspaceMBS.NSWorkspaceDecryptOperation as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the file operation modes.

Decrypt file. This operation always returns an error.

NSWorkspaceMBS.NSWorkspaceDesktopImageAllowClippingKey as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the keys for the options dictionary used with SetDesktopImageURL.

The value is a boolean, which affects the interpretation of Proportional scaling types. A false value will make the image fully visible, but there may be empty space on the sides or top and bottom. A true value will cause the image to fill the entire screen, but the image may be clipped. If this is not specified, false is assumed. Non-proportional scaling types ignore this value.
Available in Mac OS X v10.6 and later.

NSWorkspaceMBS.NSWorkspaceDesktopImageFillColorKey as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the keys for the options dictionary used with SetDesktopImageURL.

The value is an NSColor, which is used to fill any empty space around the image. If not specified, a default value is used. Currently, only colors that use or can be converted to use NSCalibratedRGBColorSpace are supported, and any alpha value is ignored.
Available in Mac OS X v10.6 and later.

Next items

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


The biggest plugin in space...