Represents a host in a window application, only one instance should appear. Manages subscriptions to various events and updates UI properties.

Hierarchy (view full)

Constructors

  • Parameters

    • backendClient: BackendClient
    • hostDescriptor: DescriptorDTO
    • uiProperties: UIProperties
    • subscriptionId: string
    • propertyRequestStrategy: IHostPropertyRequestStrategy

    Returns SubscribedHost

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.

controlType: null | number

Represents the control type of the UI.

elementDescriptor: null | DescriptorDTO

A descriptor that represents the element of the UI.
If the UI is a window, this will be null.

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.

isFocus: boolean

Represents whether the Host is focused.

Remarks

Can use updateCurrentIsFocus to update isFocus.

isInvokable: boolean

Represents whether the UI has invoke pattern.

Remarks

Can use HomObject.updateCurrentIsInvokable to update isInvokable.

isOnTop: boolean

Represents whether the Host is at the top of the window.

Remarks

Can use updateCurrentIsOnTop to update isOnTop.

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

  • Cancels the subscription to child elements by their descriptor. If the element subscription exists, it will be cancelled and removed from the components list.

    Parameters

    • elementDescriptor: DescriptorDTO

      The descriptor of the element to cancel subscription.

    Returns Promise<boolean>

    A promise that resolves to true if the subscription was found and cancelled, false otherwise.

  • 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

  • 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)
  • Retrieves child elements by their descriptor. If the element does not exist, subscribes to it and creates a new component.

    scope=undefined Arg are Not Support v2.0

    Parameters

    • elementDescriptor: DescriptorDTO

      The descriptor of the element.

    • Optional uiTreeScope: UITreeScope

      The scope of the UI tree. (Warning: Undefined are not supported below v2.0)

    Returns Promise<undefined | SubscribedHomElements>

    A promise that resolves to the matching HomElementsComponent.

  • 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 host has Transform pattern, moves the host object to the specified coordinates.
    (Transform pattern related functions are not provided yet.)

    Parameters

    • x: number

      The x-coordinate to move the host object to.

    • y: number

      The y-coordinate to move the host object to.

    • Optional space: ScreenPositionSpace

      The coordinate space to use for the movement. Defaults to 'absolute'.

    Returns Promise<void>

    Throws

    UI does not support the Transform pattern.

    Remarks

    // Move host to the (100, 100) position on the screen
    await host.moveTo(100, 100)

    // Move the host object to the (100, 100) coordinates relative to its current position.
    // await host.moveTo(100, 100, 'relative')

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

  • Cancels the subscription to the bounding box changed event.

    Returns Promise<void>

  • Cancels the subscription to the isFocus changed event.

    Returns Promise<void>

  • Cancels the subscription to the isOnTop changed event.

    Returns Promise<void>

  • Cancels the subscription to the move or resize ( end ) event.

    Returns Promise<void>

  • Cancels the subscription to the move or resize ( start ) event.

    Returns Promise<void>

  • Cancels the subscription to the name changed event.

    Returns Promise<void>

  • Cancels the subscription to the status changed event.

    Returns Promise<void>

  • Subscribes to changes in the host's bounding box property and executes the provided callback.
    SubscribedHost.boundingBox will updated when the event is called.

    Parameters

    • callback: ((host) => void)

      function invoke when the bounding box property changes.
      The callback receives a SubscribedHost object.

    Returns Promise<void>

    Throws

    If the subscription to the host bounding box change event fails.

  • Subscribes to changes in the host's isFocus property and executes the provided callback.
    SubscribedHost.isFocus will updated when the event is called.

    Parameters

    • callback: ((host) => void)

      function invoke when the isFocus property changes.
      The callback receives a SubscribedHost object.

    Returns Promise<void>

    Throws

    If the subscription to the host isFocus change event fails.

  • Subscribes to changes in the host's isOnTop property and executes the provided callback.
    SubscribedHost.isOnTop will updated when the event is called.

    Parameters

    • callback: ((host) => void)

      function when the isOnTop property changes.
      The callback receives a SubscribedHost object.

    Returns Promise<void>

    Throws

    If the subscription to the host isOnTop change event fails.

  • Subscribes to the host's move or resize ( end ) event and executes the provided callback.

    Parameters

    • callback: (() => void)

      The callback function to execute when the move or resize end event occurs.

        • (): void
        • Returns void

    Returns Promise<void>

  • Subscribes to the host's move or resize ( start ) event and executes the provided callback.

    Parameters

    • callback: (() => void)

      The callback function to execute when the move or resize start event occurs.

        • (): void
        • Returns void

    Returns Promise<void>

  • Subscribes to changes in the host's name property and executes the provided callback.
    SubscribedHost.name will updated when the event is called.

    Parameters

    • callback: ((e) => void)

      function invoke when the name property changes.
      The callback receives a SubscribedHost object.

    Returns Promise<void>

    Throws

    If the subscription to the host name change event fails.

  • Subscribes to changes in the host's status and executes the provided callback.

    Parameters

    • callback: ((host, status) => void)

      The callback function to execute when the status changes.

    Returns Promise<void>

    Throws

    If the subscription to the host status changed event fails.

  • 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 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

  • 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 host has Transform pattern, resizes the subscribed UI to the specified width and height.
    (Transform pattern related functions are not provided yet.)

    Parameters

    • width: number

      The new width of the UI.

    • height: number

      The new height of the UI.

    Returns Promise<void>

    A promise that resolves when the UI has been resized.

    Throws

    UI does not support the Transform pattern.

    Remarks

    // Resize the host to 100x100
    await host.setSize(100, 100)

    The UI result after calling setSize() is roughly as follows.
    (using file explorer 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

  • 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

  • Updates all properties of the host.

    Returns Promise<void>

    A promise resolving to void.

    Throws

    An error if failed to update the host's properties.

  • 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 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 focus state of the host.
    this will update isFocus property.

    Returns Promise<boolean>

    Example

    const isFocus = await host.updateCurrentIsFocus()

    // a new host.isFocus property
    console.log(isFocus)
  • 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 isOnTop property of the host.
    this will update isOnTop property.

    Returns Promise<boolean>

    Example

    const isOnTop = await host.updateCurrentIsOnTop()

    // a new host.isOnTop property
    console.log(isOnTop)
  • 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.