Class

SpotlightItem


Description

Used to manage results from a SpotlightQuery. Supported only on macOS. It does nothing on other operating systems.

Methods

Name

Parameters

Returns

Shared

File

FolderItem

Handle

Integer

Value

key As String

Variant

Method descriptions


SpotlightItem.File

File As FolderItem

References the file that this SpotlightItem represents.

This example uses File to access two items for each file in the loop.

Var query As New SpotlightQuery("kMDItemContentTypeTree == 'public.audio'")
query.Synchronous = True
query.Run

For i As Integer = 0 To query.Count - 1
  ListBox1.AddRow(query.Item(i).File.DisplayName)
  ListBox1.CellTextAt(ListBox1.LastAddedRowIndex, 1) = query.Item(i).Value("kMDItemDurationSeconds")
Next

Exception e As SpotlightException
  MessageBox("A Spotlight error occurred.")

SpotlightItem.Handle

Handle As Integer

Returns a handle to an MDItemRef.

This can be used in Declare statements to access features that are not provided by SpotlightQuery.


SpotlightItem.Value

Value(key As String) As Variant

Returns the value of the specified property.

The properties can be any of the ones listed in MDItem.h or any custom properties. Value returns Nil if the specified property is not present.

This example displays the name and the duration of the audio file in a ListBox.

Var query As New SpotlightQuery("kMDItemContentTypeTree == 'public.audio'")
query.Synchronous = True
query.Run
For i As Integer = 0 To query.Count - 1
  ListBox1.AddRow(query.Item(i).File.DisplayName)
  ListBox1.CellTextAt(ListBox1.LastAddedRowIndex, 1) = query.Item(i).Value("kMDItemDurationSeconds")
Next

Exception e As SpotlightException
  MessageBox("A Spotlight error occurred.")

Compatibility

Project Types

Console, Desktop, Web

Operating Systems

macOS

See also

object parent class; SpotlightException, SpotlightQuery classes.