Represents an element within the Host Object Model.

Hierarchy (view full)

Constructors

  • Constructs a new instance of HomElement.

    Parameters

    • backendClient: BackendClient

      The backend client used for communication.

    • hostDescriptor: DescriptorDTO
    • elementDescriptor: DescriptorDTO

      The descriptor of the element.

    • uiTreeScope: UITreeScope

      The scope of the UI tree for the element.

    • uiProperties: null | UIProperties

      Optional UI properties for the element.

    • propertyRequestStrategy: IHomElementPropertyRequestStrategy

    Returns HomElement

Properties

boundingBox: null | BoundingBox

Represents the bounding box of the UI.
If the UI is a window and is minimized, the Bounding box is 0.

Remarks

Can use HomObject.updateCurrentBoundingBox to update boundingBox.

children: HomElement[]

The children of the element.

Remarks

If uiTreeScope set to Element, children will be empty.

controlType: null | number

Represents the control type of the UI.

elementDescriptor: DescriptorDTO

A descriptor that represents the element of the UI.

hasValue: boolean

Represents whether the UI has value pattern.

Remarks

Can use HomObject.updateCurrentHasValue to update value.

hostDescriptor: DescriptorDTO

A descriptor that represents the window to which the UI belongs, or indicates that the UI is a window itself.

id: string = ''

The id of the UI.

isInvokable: boolean

Represents whether the UI has invoke pattern.

Remarks

Can use HomObject.updateCurrentIsInvokable to update isInvokable.

isScrollable: boolean

Represents whether the UI has scroll pattern.

Remarks

Can use HomObject.updateCurrentIsScrollable to update isScrollable.

isSelected: null | boolean

Represents whether the UI is selected.

key: string = ''

Represents the key of a UI element. The key is unique.

name: null | string

Represents the name of the UI

Remarks

Can use HomObject.updateCurrentName to update name.

scrollableView: null | ScrollableView

Represents the scrollable view of the UI.

Remarks

If the UI has scroll pattern, can use HomObject.updateCurrentScrollableView to update the scrollable view. Otherwise, scrollableView is null.

toggleState: null | boolean

Represents the toggle state of the UI.

value: null | Value

Represents the value of the UI.

Remarks

If the UI has value pattern, can using HomObject.updateCurrentValue to update the value. Otherwise, value is null.

ALLPROPERTYID: PropertyId[] = ...

Methods

  • If the UI has window pattern, close the window.
    (window pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the window pattern.

    Remarks

    The UI result after calling close() is roughly as follows.
    (using file explorer as an example)
    example

  • If the UI has ExpandCollapse pattern, collapse the UI.

    Returns Promise<void>

    Throws

    UI does not support the ExpandCollapse pattern.

    Remarks

    The UI result after calling collapse() is roughly as follows.
    (using file explorer as an example)
    example

  • If the UI has ExpandCollapse pattern, expand the UI.
    (ExpandCollapse pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the ExpandCollapse pattern.

    Remarks

    The UI result after calling expand() is roughly as follows.
    (using file explorer as an example)
    example

  • Finds a matching element in the UI tree based on a condition.

    Parameters

    • condition: ((element) => boolean)

      The condition to match.

        • (element): boolean
        • Parameters

          Returns boolean

    Returns null | HomElement

    The first matching element, or null if no match is found.

  • Finds all matching elements in the UI tree based on a condition.

    Parameters

    • condition: ((element) => boolean)

      The condition to match.

        • (element): boolean
        • Parameters

          Returns boolean

    Returns HomElement[]

    The matching elements.

  • Focus the UI.

    Returns Promise<void>

  • Retrieves the audio buffer.

    Parameters

    • callback: ((data) => void)

      The callback function to handle the audio buffer data.

        • (data): void
        • Parameters

          • data: Buffer

          Returns void

    Returns Promise<void>

    A promise that resolves when the audio buffer is retrieved.

    // Before using setValue(), must first update updateCurrentHasValue() to confirm whether there is a value pattern
    await homObject.getAudioBuffer((data: Buffer) => {
    console.log('Received audio buffer:', data);
    });
  • Gets the document text from the UI element.

    Returns Promise<string>

    A promise that resolves to the document text from the UI.

    Remarks

    // Example of getting document text from a UI element
    const text = await homObject.getDocumentText()
    console.log(text)
  • Gets the selected text from the UI element.

    Returns Promise<string>

    A promise that resolves to the selected text from the UI.

    Remarks

    // Example of getting document text from a UI element
    const text = await homObject.getSelectedText()
    console.log(text)
  • Gets the visible text from the UI element.

    Returns Promise<string>

    A promise that resolves to the visible text from the UI.

    Remarks

    // Example of getting document text from a UI element
    const text = await homObject.getVisibleText()
    console.log(text)
  • If the UI has invoke pattern, invoke the UI.
    (can use HomObject.isInvokable to check UI supports the invoke pattern.)

    Returns Promise<void>

    Throws

    UI does not support the invoke pattern.

    Example

    // Before using invoke(), must first update updateCurrentIsInvokable() to confirm whether there is an invoke pattern
    const isInvokable = await homObject.updateCurrentIsInvokable()

    if (isInvokable) {
    await homObject.invoke()
    }

    The UI result after calling invoke() is roughly as follows.
    (using file explorer as an example)
    example

  • If the UI has window pattern, restore the window.
    (Window pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the window pattern.

    Remarks

    The UI result after calling maximize() is roughly as follows.
    (using file explorer as an example)
    example

  • If the UI has window pattern, minimize the window.
    (Window pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the window pattern.

    Remarks

    The UI result after calling minimize() is roughly as follows.
    (using file explorer as an example)
    example

  • Moves the mouse into the UI center and click.

    Returns Promise<void>

    Example

    // Click the left mouse button into the UI center
    await homObject.mouseClick()

    // Click the right mouse button into the UI center
    await homObject.mouseClick({ key: 'right' })
  • Parameters

    Returns Promise<void>

  • Moves the mouse in the UI center.

    Returns Promise<void>

  • Moves the mouse into the UI center and Hold.

    Returns Promise<void>

    Example

    // Hold the left mouse button into the UI center
    await homObject.mousePress()

    // Hold the right mouse button into the UI center
    // await homObject.mousePress({ key: 'right' })
  • Parameters

    Returns Promise<void>

  • Moves the mouse into the UI center and release.

    Returns Promise<void>

    Example

    // Hold the left mouse button into the UI center before release
    await homObject.mousePress()

    // Release the left mouse button into the UI center
    await homObject.mouseRelease()

    // Release the right mouse button into the UI center
    // await homObject.mouseRelease({ key: 'right' })
  • Parameters

    Returns Promise<void>

  • Moves the mouse into the UI center and scroll down.

    Returns Promise<void>

    Example

    // Scroll down the mouse wheel into the UI center
    await homObject.mouseScrollDown()

    // Scroll down the mouse wheel into the UI center with 3 ticks
    await homObject.mouseScrollDown({ tick: 3 })

    // Scroll down the mouse wheel into the UI center with 120 amount
    await homObject.mouseScrollDown({ amount: 120 })
  • Parameters

    Returns Promise<void>

  • Moves the mouse into the UI center and scroll up.

    Returns Promise<void>

    Example

    // Scroll up the mouse wheel into the UI center
    await homObject.mouseScrollUp()

    // Scroll up the mouse wheel into the UI center with 3 ticks
    await homObject.mouseScrollUp({ tick: 3 })

    // Scroll up the mouse wheel into the UI center with 120 amount
    await homObject.mouseScrollUp({ amount: 120 })
  • Parameters

    Returns Promise<void>

  • If the UI has scroll pattern, scroll the UI horizontally.
    (can use HomObject.isScrollable to check UI supports the scroll pattern.)

    Parameters

    • amount: Amount

      The amount to scroll horizontally.

    Returns Promise<void>

    Throws

    UI does not support the scroll pattern.

    Remarks

    // Before using scrollHorizontal(), must first update updateCurrentIsScrollable() to confirm whether there is a scroll pattern
    const isScrollable = await homObject.updateCurrentIsScrollable()

    if (isScrollable) {
    await homObject.scrollHorizontal(Amount.LargeDecrement)
    }

    The UI result after calling scrollHorizontal() is roughly as follows.
    (using file explorer as an example)
    example

  • If the UI has ScrollItem pattern, Scrolls the element into view in the UI. (ScrollItem pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the ScrollItem pattern.

    Remarks

    await element.scrollIntoView()
    

    The UI result after calling scrollIntoView() is roughly as follows.
    (using photo viewer as an example)
    example

  • If the UI has scroll pattern, scroll the UI vertically.
    (can use HomObject.isScrollable to check UI supports the scroll pattern.)

    Parameters

    • amount: Amount

      The amount to scroll vertically.

    Returns Promise<void>

    Throws

    UI does not support the scroll pattern.

    Remarks

    // Before using scrollVertical(), must first update updateCurrentIsScrollable() to confirm whether there is a scroll pattern
    const isScrollable = await homObject.updateCurrentIsScrollable()

    if (isScrollable) {
    await homObject.scrollVertical(Amount.LargeDecrement)
    }

    The UI result after calling scrollVertical() is roughly as follows.
    (using file explorer as an example)
    example

  • If the UI has SelectionItem pattern, selects the UI.
    (SelectionItem pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the SelectionItem pattern.

    Remarks

    await file1.select()
    await file2.select()
    await file3.select()

    The UI result after calling select() is roughly as follows.
    (using file explorer as an example)
    example

  • If the UI has SelectionItem pattern, selects the UI and unselects all other selected UIs.
    (SelectionItem pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the SelectionItem pattern.

    Remarks

    await file1.select()
    await file2.select()
    await file3.select()

    // only file2 is selected
    await file2.selectOnly()

    The UI result after calling selectOnly() is roughly as follows.
    (using file explorer as an example)
    example

  • Asynchronously invokes the horizontal scrolling action.
    (can use HomObject.isScrollable to check UI supports the scroll pattern.)

    Parameters

    • percent: number

      Set the percentage of horizontal scrolling.

    Returns Promise<void>

    Throws

    UI does not support the scroll pattern.

    Example

    // Before using setHorizontalScrollPercent(), must first update updateCurrentIsScrollable() to confirm whether there is a scroll pattern
    const isScrollable = await homObject.updateCurrentIsScrollable()

    if (isScrollable) {
    await homObject.setHorizontalScrollPercent(50)
    }

    The UI result after calling setHorizontalScrollPercent() is roughly as follows.
    (using file explorer as an example)
    example

  • If the UI has RangeValue pattern, set value range of the UI. (RangeValue pattern related functions are not provided yet.)

    Parameters

    • value: number

    Returns Promise<void>

    Throws

    UI does not support the RangeValue pattern.

    Remarks

    await element.setRangeValue(565)
    

    The UI result after calling setRangeValue() is roughly as follows.
    (using photo viewer as an example)
    example

  • If the UI has value pattern, set the value of the UI.
    (can use HomObject.hasValue to check UI supports the value pattern.)

    Parameters

    • value: string

      Value used to set the UI.

    Returns Promise<void>

    Throws

    UI does not support the value pattern.

    Remarks

    // Before using setValue(), must first update updateCurrentHasValue() to confirm whether there is a value pattern
    const hasValue = await homObject.updateCurrentHasValue()

    if (hasValue) {
    await homObject.setValue('scrollV')
    }

    The UI result after calling setValue() is roughly as follows.
    (using file explorer as an example)
    example

  • Asynchronously invokes the vertical scrolling action.
    (can use HomObject.isScrollable to check UI supports the scroll pattern.)

    Parameters

    • percent: number

      Set the percentage of vertical scrolling.

    Returns Promise<void>

    Throws

    UI does not support the scroll pattern.

    Remarks

    // Before using setVerticalScrollPercent(), must first update updateCurrentIsScrollable() to confirm whether there is a scroll pattern
    const isScrollable = await homObject.updateCurrentIsScrollable()

    if (isScrollable) {
    await homObject.setVerticalScrollPercent(50)
    }

    The UI result after calling setVerticalScrollPercent() is roughly as follows.
    (using file explorer as an example)
    example

  • Starts the audio listening.

    Parameters

    • Optional channel: number

      channelRate, defaults to 1

    • Optional sampleRate: number

      sampleRate, defaults to 44100

    • Optional bits: number

      bits, defaults to 16

    Returns Promise<void>

    A promise that resolves when the audio listening is started.

    Example

    // Before using setValue(), must first update updateCurrentHasValue() to confirm whether there is a value pattern
    await homObject.startAudioListening()
    // or with specific parameters
    await homObject.startAudioListening(2)
    await homObject.startAudioListening(2, 16000)
    await homObject.startAudioListening(2, 16000, 8)
  • Stops the audio listening.

    Returns Promise<void>

    A promise that resolves when the audio listening is stopped.

    // Before using setValue(), must first update updateCurrentHasValue() to confirm whether there is a value pattern
    await homObject.stopAudioListening()
  • If the UI has toggle pattern, toggle the UI.
    (Toggle pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the toggle pattern.

    Remarks

    The UI result after calling toggle() is roughly as follows.
    (using google meet as an example)
    example

  • Traverse the UI tree recursively and execute a callback on each node.

    Parameters

    • callback: ((node) => void)

      The function to execute on each node.

        • (node): void
        • Parameters

          Returns void

    Returns void

  • If the UI has window pattern, restore the window.
    (Window pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the window pattern.

    Remarks

    The UI result after calling unMaximize() is roughly as follows.
    (using file explorer as an example)
    example

  • If the UI has SelectionItem pattern, unselects the UI.
    (SelectionItem pattern related functions are not provided yet.)

    Returns Promise<void>

    Throws

    UI does not support the SelectionItem pattern.

    Remarks

    await file3.unSelect()
    await file2.unSelect()
    await file1.unSelect()

    The UI result after calling unSelect() is roughly as follows.
    (using file explorer as an example)
    example

  • Updates all properties of the UI.

    Returns Promise<void>

    Remarks

    For some properties, if there is no corresponding pattern, will be null.

  • Updates the current bounding box property of the UI, this will update HomObject.boundingBox property.

    Returns Promise<BoundingBox>

    A promise that resolves to the updated bounding box property.

    Example

    const boundingBox = await homObject.updateCurrentBoundingBox()

    // a new homObject.boundingBox property
    console.log(boundingBox)
  • Updates the current children of the element.
    this will update children property.

    Returns Promise<void>

    Remarks

    If uiTreeScope set to Element, children will be empty.

  • Updates the current hasValue property of the UI, this will update HomObject.hasValue property.

    Returns Promise<boolean>

    A promise that resolves to the updated hasValue property.

    Example

    const hasValue = await homObject.updateCurrentHasValue()

    // a new homObject.hasValue property
    console.log(hasValue)

    // homObject.hasValue property can be used to check if the UI has value pattern.
    if (hasValue) {
    // setValue() only works if the UI has value pattern.
    homObject.setValue('new value')
    }
  • Updates the current isInvokable property of the UI, this will update HomObject.isInvokable property.

    Returns Promise<boolean>

    A promise that resolves to the updated isInvokable property.

    Example

    const isInvokable = await homObject.updateCurrentIsInvokable()

    // a new homObject.isInvokable property
    console.log(isInvokable)

    // homObject.isInvokable property can be used to check if the UI has invoke pattern.
    if (isInvokable) {
    // invoke() only works if the UI has invoke pattern.
    homObject.invoke()
    }
  • Updates the current isScrollable property of the UI, this will update HomObject.isScrollable property.

    Returns Promise<boolean>

    A promise that resolves to the updated isScrollable property.

    Example

    const isScrollable = await homObject.updateCurrentIsScrollable()

    // a new homObject.isScrollable property
    console.log(isScrollable)

    // homObject.isScrollable property can be used to check if the UI has scroll pattern.
    if (isScrollable) {
    // scrollVertical() only works if the UI has scroll pattern.
    homObject.scrollVertical(Amount.LargeDecrement)
    }
  • Updates the current name property of the UI, this will update HomObject.name property.

    Returns Promise<string>

    A promise that resolves to the updated name property.

    Example

    const name = await homObject.updateCurrentName()

    // a new homObject.name property
    console.log(name)
  • If the UI has scroll pattern, updates the current scrollableView property, otherwise, it will throw an error.
    this will update HomObject.scrollableView property.

    Returns Promise<ScrollableView>

    A promise that resolves to the updated scrollableView property.

    Remarks

    Can use HomObject.isScrollable to check if the UI supports the scroll pattern.

    Example

    // Before using updateCurrentScrollableView(), must first update updateCurrentIsScrollable() to confirm whether there is a scroll pattern
    const isScrollable = await homObject.updateCurrentIsScrollable()

    if (isScrollable) {
    const scrollableView = await homObject.updateCurrentScrollableView()

    // a new homObject.scrollableView property
    console.log(scrollableView)
    }

    Throws

    UI does not support the scroll pattern.

  • If the UI has value pattern, updates the current value property, otherwise, it will throw an error.
    this will update HomObject.value property.

    Returns Promise<Value>

    A promise that resolves to the updated value property.

    Remarks

    Can use HomObject.hasValue to check if the UI supports the value pattern.

    Example

    // Before using updateCurrentValue(), must first update updateCurrentHasValue() to confirm whether there is a value pattern
    const hasValue = await homObject.updateCurrentHasValue()

    if (hasValue) {
    const value = await homObject.updateCurrentValue()

    // a new homObject.value property
    console.log(value)
    }

    Throws

    UI does not support the value pattern.