UiPath Documentation
activities
latest
false

UI Automation アクティビティ

最終更新日時 2026年5月5日

添付

UI 操作の自動化で使用するために、既に開いているデスクトップ アプリケーションまたは Web ブラウザー ページにフォーカスします。

この API を使用するには、uiAutomation.<APIMethod>() の形式で UI Automation サービスを呼び出します。例: uiAutomation.Open()

定義

名前空間: UiPath.UIAutomationNext.API.Contracts

アセンブリ: UiPath.UIAutomationNext.API.Contracts (UiPath.UIAutomationNext.API.Contracts dll 内)

オーバー ロード

オーバーロード説明
Attach(String, TargetAppOptions, String, String)オブジェクト リポジトリの画面名で識別される、UI 操作の自動化で使用する特定のデスクトップ アプリケーションまたは Web ページにフォーカスします。
Attach(TargetAppModel, TargetAppOptions)TargetAppModel オブジェクトで識別される、UI 操作の自動化で使用する特定のデスクトップ アプリケーションまたは Web ページにフォーカスします。
Attach(String, String, String, NAppAttachMode, NWindowResize, NInteractionMode)オブジェクト リポジトリの画面名で識別される、UI 操作の自動化で使用する特定のデスクトップ アプリケーションまたは Web ページと、アプリまたは Web ページのその他のカスタマイズにフォーカスします。

Attach(String, TargetAppOptions, String, String)

オブジェクト リポジトリの画面名で識別される、UI 操作の自動化で使用する特定のデスクトップ アプリケーションまたは Web ページにフォーカスします。

Attach(
    string screenName,
    TargetAppOptions targetAppOptions,
    [string appName],
    [string appVersion])
Attach(
    string screenName,
    TargetAppOptions targetAppOptions,
    [string appName],
    [string appVersion])

screeName 文字列 : オブジェクト リポジトリ内に記録される文字列としてフォーカスする画面の名前です。

targetAppOptions TargetAppOptions : アプリケーションまたは Web ページにアタッチするための追加のオプションと設定:

* `Timeout Double` - Specify a number
  of seconds for which to wait for the activity to be executed before
  throwing an error. The default value is 30 seconds. When indicating
  a window in a Remote Desktop environment, the Timeout default
  setting is set to 60 seconds.
* `InteractionMode
  NInteractionMode`:
  + `HardwareEvents` - Uses the hardware
    driver to perform the action. This is the slowest API, it
    cannot work in the background, but it is compatible with all
    desktop apps.
  + `Simulate` - Simulates the action using
    accessibility APIs. Recommended in browser automation, Java
    apps, or SAP. More reliable than Hardware Events. Sends all
    text in a single action. Works even if the target
    application is not in focus. Please test if your target
    application UI element supports this.
  + `DebuggerApi` - Performs actions using
    debugger APIs. Works only for Chromium elements. Sends all
    text in one go. Works even if target app is not in focus.
    For more details, check out this [page](https://docs.uipath.com/studio/docs/chromium-api).
  + `WindowMessages` - Sends the mouse and
    keyboard input through Win32 messages. Recommended for
    desktop apps. Usually more reliable than Hardware Events.
    Sends all text in a single action. Works even if target app
    is not in focus. Please test if your target application UI
    element supports this.
  + `Background` - Runs actions in the
    background. Tries to use either Simulate or Chromium API
    where possible, while complex APIs (image, native text)
    run as usual, in the foreground. It is highly recommended to
    use this API with the [Verify Execution](https://docs.uipath.com/activities/other/latest/user-guide/project-settings-ui-automation)
    feature.
* `OpenMode NAppOpenMode` - choose when
  to open the app:
  + `Never` (never open the
    application)
  + `IfNotOpen` (open only if the
    application is closed, this is the default selection, only
    works if `FilePath` or `URL`
    are provided)
  + `Always` (open another instance of the
    application even if one is already open, only works if
    `FilePath` or `URL` are
    provided)
* `WindowResize NWindowResize` - choose
  the size of the window:
  + `None`
  + `Maximize`
  + `Restore`
  + `Minimize`
* `UserDataFolderMode
  BrowserUserDataFolderMode` - The
  `UserDataFolderMode` you want to set. It is used
  to start the browser with a specific user data folder.
  + `Automatic` - Picture In Picture mode
    uses a different folder than the default mode, automatically
    generated if `UserDataFolderPath` is not
    set.
  + `DefaultFolder` - Uses the default
    browser folder, no matter if it runs in the main or PIP
    session.
  + `CustomFolder` - Uses the folder
    specified in `UserDataFolderPath` or an auto
    generated path if `UserDataFolderPath` is not
    set.
* `UserDataFolderPath String` - The
  user data folder that the browser uses. Defaults to
  `%LocalAppData%\UiPath\PIP Browser
  Profiles\BrowserType` if not set.
* `IsIncognito Boolean` - input
  `True` if you want to open the browser in
  incognito mode. By default it's set to `False`.
* `WebDriverMode NWebDriverMode` -
  Indicates how the WebDriver is used when opening a new browser
  session. The following options are available:
  + `Disabled` - Disables the use of
    WebDriver.
  + `WithGUI` - The GUI of the browser is
    displayed.
  + `Headless` - The browser is launched
    silently, with no GUI.
* `Timeout Double` - Specify a number
  of seconds for which to wait for the activity to be executed before
  throwing an error. The default value is 30 seconds. When indicating
  a window in a Remote Desktop environment, the Timeout default
  setting is set to 60 seconds.
* `InteractionMode
  NInteractionMode`:
  + `HardwareEvents` - Uses the hardware
    driver to perform the action. This is the slowest API, it
    cannot work in the background, but it is compatible with all
    desktop apps.
  + `Simulate` - Simulates the action using
    accessibility APIs. Recommended in browser automation, Java
    apps, or SAP. More reliable than Hardware Events. Sends all
    text in a single action. Works even if the target
    application is not in focus. Please test if your target
    application UI element supports this.
  + `DebuggerApi` - Performs actions using
    debugger APIs. Works only for Chromium elements. Sends all
    text in one go. Works even if target app is not in focus.
    For more details, check out this [page](https://docs.uipath.com/ja/studio/docs/chromium-api).
  + `WindowMessages` - Sends the mouse and
    keyboard input through Win32 messages. Recommended for
    desktop apps. Usually more reliable than Hardware Events.
    Sends all text in a single action. Works even if target app
    is not in focus. Please test if your target application UI
    element supports this.
  + `Background` - Runs actions in the
    background. Tries to use either Simulate or Chromium API
    where possible, while complex APIs (image, native text)
    run as usual, in the foreground. It is highly recommended to
    use this API with the [Verify Execution](https://docs.uipath.com/ja/activities/other/latest/user-guide/project-settings-ui-automation)
    feature.
* `OpenMode NAppOpenMode` - choose when
  to open the app:
  + `Never` (never open the
    application)
  + `IfNotOpen` (open only if the
    application is closed, this is the default selection, only
    works if `FilePath` or `URL`
    are provided)
  + `Always` (open another instance of the
    application even if one is already open, only works if
    `FilePath` or `URL` are
    provided)
* `WindowResize NWindowResize` - choose
  the size of the window:
  + `None`
  + `Maximize`
  + `Restore`
  + `Minimize`
* `UserDataFolderMode
  BrowserUserDataFolderMode` - The
  `UserDataFolderMode` you want to set. It is used
  to start the browser with a specific user data folder.
  + `Automatic` - Picture In Picture mode
    uses a different folder than the default mode, automatically
    generated if `UserDataFolderPath` is not
    set.
  + `DefaultFolder` - Uses the default
    browser folder, no matter if it runs in the main or PIP
    session.
  + `CustomFolder` - Uses the folder
    specified in `UserDataFolderPath` or an auto
    generated path if `UserDataFolderPath` is not
    set.
* `UserDataFolderPath String` - The
  user data folder that the browser uses. Defaults to
  `%LocalAppData%\UiPath\PIP Browser
  Profiles\BrowserType` if not set.
* `IsIncognito Boolean` - input
  `True` if you want to open the browser in
  incognito mode. By default it's set to `False`.
* `WebDriverMode NWebDriverMode` -
  Indicates how the WebDriver is used when opening a new browser
  session. The following options are available:
  + `Disabled` - Disables the use of
    WebDriver.
  + `WithGUI` - The GUI of the browser is
    displayed.
  + `Headless` - The browser is launched
    silently, with no GUI.

appName String : アタッチするアプリケーションの名前です。このパラメーターはデスクトップ アプリケーションに適用されます。

appVersion string : アタッチ先のアプリケーションのバージョンです。このパラメーターはデスクトップ アプリケーションに適用されます。

Attach(TargetAppModel, TargetAppOptions)

TargetAppModel オブジェクトで識別される、UI 操作の自動化で使用する特定のデスクトップ アプリケーションまたは Web ページにフォーカスします。

Attach(
    TargetAppModel targetApp,
    [TargetAppOptions targetAppOptions]))
Attach(
    TargetAppModel targetApp,
    [TargetAppOptions targetAppOptions]))

targetApp TargetAppModel : アタッチする対象のアプリケーションまたは Web ページです。これは、アプリケーションに関する情報を提供する TargetAppModel タイプのオブジェクトです。

* `Selector String` - An XML fragment
  that stores the attributes of a user interface element.
* `FilePath String` - If the
  application is not a web browser, specifies the full path of the
  executable file to open.
* `Arguments String` - If the
  application is not a web browser, you can specify parameters to pass
  to the target application at startup.
* `Url
  String` - If the application is a web browser, specifies
  the URL of the web page to open.
* `Title
  String` - The title of the application or browser.
* `Selector String` - An XML fragment
  that stores the attributes of a user interface element.
* `FilePath String` - If the
  application is not a web browser, specifies the full path of the
  executable file to open.
* `Arguments String` - If the
  application is not a web browser, you can specify parameters to pass
  to the target application at startup.
* `Url
  String` - If the application is a web browser, specifies
  the URL of the web page to open.
* `Title
  String` - The title of the application or browser.

targetAppOptions TargetAppOptions : アプリケーションまたは Web ページにアタッチするための追加のオプションと設定:

* `Timeout Double` - Specify a number of seconds
  for which to wait for the activity to be executed before throwing an
  error. The default value is 30 seconds. When indicating a window in
  a Remote Desktop environment, the Timeout default setting is set to
  60 seconds.
* `InteractionMode NInteractionMode`:
  + `HardwareEvents` - Uses the hardware driver
    to perform the action. This is the slowest API, it cannot
    work in the background, but it is compatible with all
    desktop apps.
  + `Simulate` - Simulates the action using
    accessibility APIs. Recommended in browser automation, Java
    apps, or SAP. More reliable than Hardware Events. Sends all
    text in a single action. Works even if the target
    application is not in focus. Please test if your target
    application UI element supports this.
  + `DebuggerApi` - Performs actions using
    debugger APIs. Works only for Chromium elements. Sends all
    text in one go. Works even if target app is not in focus.
    For more details, check out this [page](https://docs.uipath.com/studio/docs/chromium-api).
  + `WindowMessages` - Sends the mouse and
    keyboard input through Win32 messages. Recommended for
    desktop apps. Usually more reliable than Hardware Events.
    Sends all text in a single action. Works even if target app
    is not in focus. Please test if your target application UI
    element supports this.
  + `Background` - Runs actions in the
    background. Tries to use either Simulate or Chromium API
    where possible, while complex APIs (image, native text)
    run as usual, in the foreground. It is highly recommended to
    use this API with the [Verify Execution](https://docs.uipath.com/activities/other/latest/user-guide/project-settings-ui-automation)
    feature.
* `OpenMode NAppOpenMode` - choose when to open
  the app:
  + `Never` (never open the application)
  + `IfNotOpen` (open only if the application is
    closed, this is the default selection, only works if
    `FilePath` or `URL` are
    provided)
  + `Always` (open another instance of the
    application even if one is already open, only works if
    `FilePath` or `URL` are
    provided)
* `WindowResize NWindowResize` - choose the size
  of the window:
  + `None`
  + `Maximize`
  + `Restore`
  + `Minimize`
* `UserDataFolderMode BrowserUserDataFolderMode`
  - The `UserDataFolderMode` you want to set. It is
  used to start the browser with a specific user data folder.
  + `Automatic` - Picture In Picture mode uses a
    different folder than the default mode, automatically
    generated if `UserDataFolderPath` is not
    set.
  + `DefaultFolder` - Uses the default browser
    folder, no matter if it runs in the main or PIP
    session.
  + `CustomFolder` - Uses the folder specified in
    `UserDataFolderPath` or an auto generated
    path if `UserDataFolderPath` is not set.
* `UserDataFolderPath String` - The user data
  folder that the browser uses. Defaults to
  `%LocalAppData%\UiPath\PIP Browser
  Profiles\BrowserType` if not set.
* `IsIncognito Boolean` - input
  `True` if you want to open the browser in
  incognito mode. By default it's set to `False`.
* `WebDriverMode NWebDriverMode` - Indicates how
  the WebDriver is used when opening a new browser session. The
  following options are available:
  + `Disabled` - Disables the use of
    WebDriver.
  + `WithGUI` - The GUI of the browser is
    displayed.
  + `Headless` - The browser is launched
    silently, with no GUI.
* `Timeout Double` - Specify a number of seconds
  for which to wait for the activity to be executed before throwing an
  error. The default value is 30 seconds. When indicating a window in
  a Remote Desktop environment, the Timeout default setting is set to
  60 seconds.
* `InteractionMode NInteractionMode`:
  + `HardwareEvents` - Uses the hardware driver
    to perform the action. This is the slowest API, it cannot
    work in the background, but it is compatible with all
    desktop apps.
  + `Simulate` - Simulates the action using
    accessibility APIs. Recommended in browser automation, Java
    apps, or SAP. More reliable than Hardware Events. Sends all
    text in a single action. Works even if the target
    application is not in focus. Please test if your target
    application UI element supports this.
  + `DebuggerApi` - Performs actions using
    debugger APIs. Works only for Chromium elements. Sends all
    text in one go. Works even if target app is not in focus.
    For more details, check out this [page](https://docs.uipath.com/ja/studio/docs/chromium-api).
  + `WindowMessages` - Sends the mouse and
    keyboard input through Win32 messages. Recommended for
    desktop apps. Usually more reliable than Hardware Events.
    Sends all text in a single action. Works even if target app
    is not in focus. Please test if your target application UI
    element supports this.
  + `Background` - Runs actions in the
    background. Tries to use either Simulate or Chromium API
    where possible, while complex APIs (image, native text)
    run as usual, in the foreground. It is highly recommended to
    use this API with the [Verify Execution](https://docs.uipath.com/ja/activities/other/latest/user-guide/project-settings-ui-automation)
    feature.
* `OpenMode NAppOpenMode` - choose when to open
  the app:
  + `Never` (never open the application)
  + `IfNotOpen` (open only if the application is
    closed, this is the default selection, only works if
    `FilePath` or `URL` are
    provided)
  + `Always` (open another instance of the
    application even if one is already open, only works if
    `FilePath` or `URL` are
    provided)
* `WindowResize NWindowResize` - choose the size
  of the window:
  + `None`
  + `Maximize`
  + `Restore`
  + `Minimize`
* `UserDataFolderMode BrowserUserDataFolderMode`
  - The `UserDataFolderMode` you want to set. It is
  used to start the browser with a specific user data folder.
  + `Automatic` - Picture In Picture mode uses a
    different folder than the default mode, automatically
    generated if `UserDataFolderPath` is not
    set.
  + `DefaultFolder` - Uses the default browser
    folder, no matter if it runs in the main or PIP
    session.
  + `CustomFolder` - Uses the folder specified in
    `UserDataFolderPath` or an auto generated
    path if `UserDataFolderPath` is not set.
* `UserDataFolderPath String` - The user data
  folder that the browser uses. Defaults to
  `%LocalAppData%\UiPath\PIP Browser
  Profiles\BrowserType` if not set.
* `IsIncognito Boolean` - input
  `True` if you want to open the browser in
  incognito mode. By default it's set to `False`.
* `WebDriverMode NWebDriverMode` - Indicates how
  the WebDriver is used when opening a new browser session. The
  following options are available:
  + `Disabled` - Disables the use of
    WebDriver.
  + `WithGUI` - The GUI of the browser is
    displayed.
  + `Headless` - The browser is launched
    silently, with no GUI.

Attach(String, String, String, NAppAttachMode, NWindowResize, NInteractionMode)

オブジェクト リポジトリの画面名で識別される、UI 操作の自動化で使用する特定のデスクトップ アプリケーションまたは Web ページと、アプリまたは Web ページのその他のカスタマイズにフォーカスします。

Attach(string screenName,
    [string appName],
    [string appVersion],
    [NAppAttachMode appAttachMode],
    [NWindowResize windowResize],
    [NInteractionMode interactionMode]))
Attach(string screenName,
    [string appName],
    [string appVersion],
    [NAppAttachMode appAttachMode],
    [NWindowResize windowResize],
    [NInteractionMode interactionMode]))

screeName 文字列 : オブジェクト リポジトリ内に記録される文字列としてフォーカスする画面の名前です。

appName String : アタッチするアプリケーションの名前です。このパラメーターはデスクトップ アプリケーションに適用されます。

appVersion string : アタッチ先のアプリケーションのバージョンです。このパラメーターはデスクトップ アプリケーションに適用されます。

appAttachMode NAppAttachMode : * ByProcessName 以降の API は、指定したアプリと同じプロセス名を持つすべてのウィンドウを検索します。* ByInstance 以降の API は、すべての親ウィンドウと子ウィンドウ (アラート、ポップアップなど) を含む、指定したアプリケーション インスタンスを検索します。アプリケーションの他のインスタンスは除外されます。* SingleWindow 以降の API では、指定したウィンドウでのみ検索が実行されます。

windowResize NWindowResize : ウィンドウのサイズを選択します。

* `None`
* `Maximize`
* `Restore`
* `Minimize`
* `None`
* `Maximize`
* `Restore`
* `Minimize`

interactionMode NInteractionMode : ロボットが対象のアプリケーションと対話する API を、以下より選択します。

* `HardwareEvents` - Uses the hardware driver to
  perform the action. This is the slowest API, it cannot work in
  the background, but it is compatible with all desktop apps.
* `Simulate` - Simulates the action using accessibility
  APIs. Recommended in browser automation, Java apps, or SAP. More
  reliable than Hardware Events. Sends all text in a single action.
  Works even if the target application is not in focus. Please test if
  your target application UI element supports this.
* `DebuggerApi` - Performs actions using debugger APIs.
  Works only for Chromium elements. Sends all text in one go. Works
  even if target app is not in focus. For more details, check out this
  [page](https://docs.uipath.com/studio/docs/chromium-api).
* `WindowMessages` - Sends the mouse and keyboard input
  through Win32 messages. Recommended for desktop apps. Usually more
  reliable than Hardware Events. Sends all text in a single action.
  Works even if target app is not in focus. Please test if your target
  application UI element supports this.
* `Background` - Runs actions in the background. Tries
  to use either Simulate or Chromium API where possible, while complex
  APIs (image, native text) run as usual, in the foreground. It is
  highly recommended to use this API with the [Verify Execution](https://docs.uipath.com/activities/other/latest/user-guide/project-settings-ui-automation)
  feature.
* `HardwareEvents` - Uses the hardware driver to
  perform the action. This is the slowest API, it cannot work in
  the background, but it is compatible with all desktop apps.
* `Simulate` - Simulates the action using accessibility
  APIs. Recommended in browser automation, Java apps, or SAP. More
  reliable than Hardware Events. Sends all text in a single action.
  Works even if the target application is not in focus. Please test if
  your target application UI element supports this.
* `DebuggerApi` - Performs actions using debugger APIs.
  Works only for Chromium elements. Sends all text in one go. Works
  even if target app is not in focus. For more details, check out this
  [page](https://docs.uipath.com/ja/studio/docs/chromium-api).
* `WindowMessages` - Sends the mouse and keyboard input
  through Win32 messages. Recommended for desktop apps. Usually more
  reliable than Hardware Events. Sends all text in a single action.
  Works even if target app is not in focus. Please test if your target
  application UI element supports this.
* `Background` - Runs actions in the background. Tries
  to use either Simulate or Chromium API where possible, while complex
  APIs (image, native text) run as usual, in the foreground. It is
  highly recommended to use this API with the [Verify Execution](https://docs.uipath.com/ja/activities/other/latest/user-guide/project-settings-ui-automation)
  feature.

WebDriverMode をヘッドレスとして実行する

ヘッドレス構成で WebDriverMode を操作するには、以下の手順に従ってください。

まず、画面の変数を定義します。uiAutomation.Open 関数を使用して、任意のブラウザー (この例では Edge) で新しいアプリケーションを開きます。その後、オーバーロードで Options クラスを使用して特定のブラウザー オプションを指定します。これらのオプションのうち、webDriverModeNWebDriverMode.Headless に設定します。

対応するコードは以下のようになります。

var screen = uiAutomation.Open(Descriptors.NewApplication.Edge, Options.AppOpen().WithBrowserOptions(webDriverMode: NWebDriverMode.Headless));
var screen = uiAutomation.Open(Descriptors.NewApplication.Edge, Options.AppOpen().WithBrowserOptions(webDriverMode: NWebDriverMode.Headless));

このコードは、WebDriver をヘッドレス モードに設定し、ブラウザーを開いて表示しなくてもそのブラウザーを自動化できるようにします。

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得