UiPath Documentation
activities
latest
false
UI Automation アクティビティ
重要 :
このコンテンツの一部は機械翻訳によって処理されており、完全な翻訳を保証するものではありません。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。

スクリーンショットを作成

UI Automation のコード化されたオートメーション API でスクリーンショットを作成: 指定した UI 要素またはアプリケーションのスクリーンショットを作成して、ファイルに保存します。

指定した UI 要素またはアプリケーションのスクリーンショットを作成して、ファイルに保存します。

この API は Open または Attach の後に追加する必要があります。

定義​

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

アセンブリ: UiPath.UIAutomationNext.API.Models (in UiPath.UIAutomationNext.API.Models dll)

オーバー ロード​

オーバーロード説明
TakeScreenshot(IElementDescriptor, TakeScreenshotOptions)指定した UI 要素またはアプリケーションのスクリーンショットを作成して、オブジェクト リポジトリの要素の記述子によって識別されるファイルに保存します。
TakeScreenshot(IElementDescriptor, String)オブジェクト リポジトリの要素の記述子によって識別される、指定した UI 要素またはアプリケーションのスクリーンショットを、ファイル名を指定して作成しファイルに保存します。
TakeScreenshot(String, TakeScreenshotOptions)指定した UI 要素またはアプリケーションのスクリーンショットを作成して、オブジェクト リポジトリの文字列で識別されるファイルに保存します。同時に、その他の設定も行います。
TakeScreenshot(String, String)指定した UI 要素またはアプリケーションのスクリーンショットを作成して、オブジェクト リポジトリの文字列で識別されるファイルに保存します。同時に、その他の設定も行います。
TakeScreenshot(RuntimeTarget, TakeScreenshotOptions)オブジェクト リポジトリ要素のランタイム インスタンスによって識別される、指定した UI 要素またはアプリケーションのスクリーンショットを作成して、ファイルに保存します。同時に、その他の設定も行います。
TakeScreenshot(TargetAnchorableModel, TakeScreenshotOptions)TargetAnchorableModel オブジェクトによって識別される、指定した UI 要素またはアプリケーションのスクリーンショットを作成して、ファイルに保存します。同時に、その他の設定も行います。
TakeScreenshot(TargetAnchorableModel, String)TargetAnchorableModel オブジェクトで識別される、指定した UI 要素またはアプリケーションのスクリーンショットを作成して、ファイル名を指定してファイルに保存します。

TakeScreenshot(IElementDescriptor, TakeScreenshotOptions)​

指定した UI 要素またはアプリケーションのスクリーンショットを作成して、オブジェクト リポジトリの要素の記述子によって識別されるファイルに保存します。

TakeScreenhot(
    IElementDescriptor elementDescriptor,
    TakeScreenshotOptions takeScreenshotOptions)
TakeScreenhot(
    IElementDescriptor elementDescriptor,
    TakeScreenshotOptions takeScreenshotOptions)

elementDescriptor IElementDescriptor: スクリーンショットの取得元の要素記述子です。デスクトップ全体のスクリーンショットを作成するには、 null を残します。

takeScreenshotOptions TakeScreenshotOptions: スクリーンショットをカスタマイズするための追加オプションです。次のカスタマイズを選択できます。

* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds) to wait for the API to run before the `SelectorNotFoundException` error is thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing the API. The default amount of time is 0.3 seconds (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the
    API begins performing any operations. The default amount of time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to save.
* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds) to wait for the API to run before the `SelectorNotFoundException` error is thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing the API. The default amount of time is 0.3 seconds (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the
    API begins performing any operations. The default amount of time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to save.

TakeScreenshot(IElementDescriptor, String)​

オブジェクト リポジトリの要素の記述子によって識別される、指定した UI 要素またはアプリケーションのスクリーンショットを、ファイル名を指定して作成しファイルに保存します。

TakeScreenhot(
    IElementDescriptor elementDescriptor,
    string fileName)
TakeScreenhot(
    IElementDescriptor elementDescriptor,
    string fileName)

elementDescriptor IElementDescriptor: スクリーンショットの取得元の要素記述子です。デスクトップ全体のスクリーンショットを作成するには、 null を残します。

fileName String: 保存するファイルの名前です。

TakeScreenshot(String, TakeScreenshotOptions)​

指定した UI 要素またはアプリケーションのスクリーンショットを作成して、オブジェクト リポジトリの文字列で識別されるファイルに保存します。同時に、その他の設定も行います。

TakeScreenhot(
    string target,
    TakeScreenshotOptions takeScreenshotOptions)
TakeScreenhot(
    string target,
    TakeScreenshotOptions takeScreenshotOptions)

target String: オブジェクト リポジトリの文字列で識別される、スクリーンショットの取得元のターゲットです。デスクトップ全体のスクリーンショットを作成するには、 null を残します。

takeScreenshotOptions TakeScreenshotOptions: スクリーンショットをカスタマイズするための追加オプションです。次のカスタマイズを選択できます。

* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds) to wait for the API to run before the `SelectorNotFoundException` error is thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing the API. The default amount of time is 0.3 seconds (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API begins performing any operations. The default amount of time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to save.
* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds) to wait for the API to run before the `SelectorNotFoundException` error is thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing the API. The default amount of time is 0.3 seconds (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API begins performing any operations. The default amount of time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to save.

TakeScreenshot(String, String)​

指定した UI 要素またはアプリケーションのスクリーンショットを作成して、オブジェクト リポジトリの文字列で識別されるファイルに保存します。同時に、その他の設定も行います。

TakeScreenhot(
    string target,
    string fileName)
TakeScreenhot(
    string target,
    string fileName)

target String: オブジェクト リポジトリの文字列で識別される、スクリーンショットの取得元のターゲットです。デスクトップ全体のスクリーンショットを作成するには、 null を残します。

fileName String: 保存するファイルの名前です。

TakeScreenshot(RuntimeTarget, TakeScreenshotOptions)​

オブジェクト リポジトリ要素のランタイム インスタンスによって識別される、指定した UI 要素またはアプリケーションのスクリーンショットを作成して、ファイルに保存します。同時に、その他の設定も行います。

TakeScreenhot(
    RuntimeTarget target,
    TakeScreenshotOptions takeScreenshotOptions)
TakeScreenhot(
    RuntimeTarget target,
    TakeScreenshotOptions takeScreenshotOptions)

target RuntimeTarget: スクリーンショットの取得元のターゲットです。オブジェクト リポジトリの要素の実行時のインスタンスによって識別されます。デスクトップ全体のスクリーンショットを作成するには、 null を残します。

takeScreenshotOptions TakeScreenshotOptions: スクリーンショットをカスタマイズするための追加オプションです。次のカスタマイズを選択できます。

* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds) to wait for the API to run before the `SelectorNotFoundException` error is thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing the API. The default amount of time is 0.3 seconds (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API begins performing any operations. The default amount of time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to save.
* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds) to wait for the API to run before the `SelectorNotFoundException` error is thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing the API. The default amount of time is 0.3 seconds (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API begins performing any operations. The default amount of time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to save.

TakeScreenshot(TargetAnchorableModel, TakeScreenshotOptions)​

TargetAnchorableModel オブジェクトによって識別される、指定した UI 要素またはアプリケーションのスクリーンショットを作成して、ファイルに保存します。同時に、その他の設定も行います。

TakeScreenhot(
    TargetAnchorableModel target,
    TakeScreenshotOptions takeScreenshotOptions)
TakeScreenhot(
    TargetAnchorableModel target,
    TakeScreenshotOptions takeScreenshotOptions)

target TargetAnchorableModel: スクリーンショットの取得元のターゲットで、 TargetAnchorableModel オブジェクトで識別されます。デスクトップ全体のスクリーンショットを作成するには、 null を残します。

takeScreenshotOptions TakeScreenshotOptions: スクリーンショットをカスタマイズするための追加オプションです。次のカスタマイズを選択できます。

* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds) to wait for the API to run before the `SelectorNotFoundException` error is thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing the API. The default amount of time is 0.3 seconds (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API begins performing any operations. The default amount of time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to save.
* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds) to wait for the API to run before the `SelectorNotFoundException` error is thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing the API. The default amount of time is 0.3 seconds (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API begins performing any operations. The default amount of time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to save.

TakeScreenshot(TargetAnchorableModel, String)​

TargetAnchorableModel オブジェクトで識別される、指定した UI 要素またはアプリケーションのスクリーンショットを作成して、ファイル名を指定してファイルに保存します。

TakeScreenhot(
    TargetAnchorableModel target, 
    string fileName)
TakeScreenhot(
    TargetAnchorableModel target, 
    string fileName)

target TargetAnchorableModel: スクリーンショットの取得元のターゲットで、 TargetAnchorableModel オブジェクトで識別されます。デスクトップ全体のスクリーンショットを作成するには、 null を残します。

fileName String: 保存するファイルの名前です。

コード例​

ここでは、サンプル コードの実装について簡単に説明します。

このコード行では、スクリーンショットを保存するファイル パスを設定します。

var filePath = "C:\\samplefile.jpg";
var filePath = "C:\\samplefile.jpg";

このコマンドは、すでに開いているアプリケーションから画面にアタッチします。

var sampleApp = uiAutomation.Attach(Descriptors.NewApplication.NewScreen);
var sampleApp = uiAutomation.Attach(Descriptors.NewApplication.NewScreen);

ここで TakeScreenshot API が呼び出され、画面上で新しく指定された要素のスクリーンショットがキャプチャされて、定義されたファイル パスに保存されます。

sampleApp.TakeScreenshot(Descriptors.NewApplication.NewScreen.NewElement, filePath);
sampleApp.TakeScreenshot(Descriptors.NewApplication.NewScreen.NewElement, filePath);

指定された filePath にスクリーンショット ファイルが存在するかどうかを確認します。

var fileExists = system.FileExists(filePath);
var fileExists = system.FileExists(filePath);

最後に、このステートメントは、スクリーンショット ファイルがターゲット filePath に正常に保存されたことを確認します。

testing.VerifyAreEqual(fileExists, true);
testing.VerifyAreEqual(fileExists, true);

オプションを追加する​

コードにオプションを追加する方法は 2 つあります。

その 1 つは、適切なオーバーロードを使用することです。Ctrl + Space を押すと、IntelliSense が表示され、優先するオーバーロードを参照して選択できます。パラメーターが事前に設定されているオーバーロードを選択することもできます。省略可能なパラメーターは、角括弧で囲まれて示されます。

windowResize のような 1 つの設定を初期化する場合は、以下の構文を使用できます。

var sampleApp = uiAutomation.Attach(Descriptors.NewApplication.NewScreen, windowResize: NWindowResize.Restore);
var sampleApp = uiAutomation.Attach(Descriptors.NewApplication.NewScreen, windowResize: NWindowResize.Restore);

オプションを追加する別の方法は、Attach などの一般的なオプション オーバーロードを使用し、それを Options クラスと組み合わせることです。これにより、パラメーターをカスタマイズする際の柔軟性が多少高まります。

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

接続

ヘルプ リソース サポート(opens in new window)

学習する UiPath アカデミー(opens in new window)

質問する UiPath フォーラム(opens in new window)

最新情報を取得