活动
最新
False
横幅背景图像
工作流活动
上次更新日期 2024年4月22日

适用于 HTML 表单和标注的 API

下表列出了构建自定义 HTML 表单和标注时可以使用的 UiPath 特定 API。 这些 API 可以在 HTML 表单中独立使用,用于生成表单大小的调整,也可以用作消息以发送回 Studio,以便您的触发器工作流可以继续执行。 这些 API 以 JavaScript 形式编写。

表单和标注

下表显示了以 HTML 格式构建表单和标注时可以使用的 API。 这些 API 可以充当事件侦听器并触发回调函数 e ,您稍后可以使用该函数来访问表单或标注的其他属性,例如高度、宽度或顶部。 此外,您可以按表单上的“检查”,然后直接在控制台中写入属性,以测试其他属性。

您还可以使用 API 获取和设置表单值,以及触发表单事件。

API描述JavaScript 示例
uiPath.form.isVisible检查屏幕上当前是否显示表单。 它返回一个布尔值,指示表单是可见还是隐藏。
if (uiPath.form.isVisible === true){
    console.log("The form is visible");
} else {
    console.log("The form is not visible");
}if (uiPath.form.isVisible === true){
    console.log("The form is visible");
} else {
    console.log("The form is not visible");
}
uiPathApi.form.addEventListener("visibilityChanged", (e) => {})设置事件侦听器以检测表单可见性状态的更改。 当表单的可见性更改时,将执行指定的回调函数。 这提供了一个机会,让您可以在表单变为可见或隐藏时执行操作或更新。 回调函数中的 e 参数表示事件,您可以访问其属性以确定新的可见性状态,例如 e.detail
uiPathApi.form.addEventListener("visibilityChanged", (e) => {
                    console.log("form visibility changed triggered: " + e.detail);
                }); uiPathApi.form.addEventListener("visibilityChanged", (e) => {
                    console.log("form visibility changed triggered: " + e.detail);
                });
uiPathApi.form.addEventListener("locationChanged", (e) => {})设置一个事件侦听器,以响应表单位置的变化。 当表单的位置更改时,将执行提供的回调函数。 在回调函数中,您可以访问表示事件的 e 参数。 此事件对象包含有关位置更改的信息,例如表单的新左侧 (e.detail.left) 和顶部坐标 (e.detail.top)。
uiPathApi.form.addEventListener("locationChanged", (e) => {
                    window.formLocationChangedArg = e.detail.left + " " + e.detail.top;
                    window.formLocationChangedCount++;
                    console.log("form location changed triggered: " + window.formLocationChangedArg);
                });uiPathApi.form.addEventListener("locationChanged", (e) => {
                    window.formLocationChangedArg = e.detail.left + " " + e.detail.top;
                    window.formLocationChangedCount++;
                    console.log("form location changed triggered: " + window.formLocationChangedArg);
                });
getValue: function (elementId)用于检索表单值。
getValue: function (elementId) {
                if (elementId == 'getArray') {
                    return [1, 2, 3];
                }getValue: function (elementId) {
                if (elementId == 'getArray') {
                    return [1, 2, 3];
                }
setValue: function (elementId, value)用于设置表单值。
setValue: function (elementId, value) {
                // execute this to throw in case the form element does not exist
                $("#" + elementId).val().toString();
                $("#" + elementId).val(value);
            },setValue: function (elementId, value) {
                // execute this to throw in case the form element does not exist
                $("#" + elementId).val().toString();
                $("#" + elementId).val(value);
            },
sendMessage: function (id, value)用于触发表单事件,例如 已关闭。 在 表单触发器活动中,您使用此 API 创建的任何表单事件都只能作为 表单消息 事件进行访问。
sendMessage: function (id, value) { }sendMessage: function (id, value) { }

标注

下表显示了以 HTML 格式构建标注时可以使用的 API。 这些 API 允许您提取有关标注绑定到的目标元素的详细信息。 这些 API 充当事件侦听器并触发回调函数 e ,您稍后可以使用该函数来访问目标的其他属性,例如高度、宽度和顶部。 此外,您还可以通过在标注上按“检查”,然后直接在控制台中写入属性来测试其他属性。
API描述JavaScript 示例
uiPathApi.target.visibile检查与标注关联的目标元素当前在屏幕上是否可见。 它返回一个布尔值,指示元素是可见还是隐藏。
if (uiPath.target.isVisible === true){
    console.log("The target is visible");
} else {
    console.log("The target is not visible");
}if (uiPath.target.isVisible === true){
    console.log("The target is visible");
} else {
    console.log("The target is not visible");
}
uiPathApi.target.addEventListener("visibilityChanged", (e) => {})为目标元素可见性的更改设置事件侦听器。 当元素的可见性更改时,将执行指定的回调函数。 然后,您可以使用回调函数获取有关目标可见性的详细信息,并配置计数器以跟踪目标可见性更改的次数。
uiPathApi.target.addEventListener("visibilityChanged", (e) => {
                    console.log("target visibility changed triggered: " + e.detail);
                    window.targetVisibilityChangedArg = e.detail;
                    window.targetVisibilityChangedCount++;
                });uiPathApi.target.addEventListener("visibilityChanged", (e) => {
                    console.log("target visibility changed triggered: " + e.detail);
                    window.targetVisibilityChangedArg = e.detail;
                    window.targetVisibilityChangedCount++;
                });
uiPathApi.target.addEventListener("locationChanged", (e) => {})设置一个事件侦听器,以响应目标元素位置(左侧或顶部)的变化。 当元素的位置更改时,将执行提供的回调函数。 然后,您可以使用回调函数获取有关目标当前位置的详细信息,并为其配置计数器,以便知道位置更改了多少次。
uiPathApi.target.addEventListener("locationChanged", (e) => {
                    window.targetLocationChangedArg = e.detail.left + " " + e.detail.top;
                    window.targetLocationChangedCount++;
                    console.log("target location changed triggered: " + window.targetLocationChangedArg);
                }); uiPathApi.target.addEventListener("locationChanged", (e) => {
                    window.targetLocationChangedArg = e.detail.left + " " + e.detail.top;
                    window.targetLocationChangedCount++;
                    console.log("target location changed triggered: " + window.targetLocationChangedArg);
                });
uiPathApi.target.addEventListener("sizeChanged", (e) => {})设置事件侦听器以检测目标元素大小(宽度或高度)的变化。 当元素的大小发生变化时,将执行指定的回调函数。 然后,您可以获取目标元素的宽度和高度,并配置计数器以跟踪目标大小的更改次数。
uiPathApi.target.addEventListener("sizeChanged", (e) => {
                    window.targetSizeChangedArg = e.detail.width + " " + e.detail.height;
                    window.targetSizeChangedCount++;
                    console.log("target size changed triggered: " + window.targetSizeChangedArg); uiPathApi.target.addEventListener("sizeChanged", (e) => {
                    window.targetSizeChangedArg = e.detail.width + " " + e.detail.height;
                    window.targetSizeChangedCount++;
                    console.log("target size changed triggered: " + window.targetSizeChangedArg);
  • 表单和标注
  • 标注

此页面是否有帮助?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath 白色徽标
信任与安全
© 2005-2024 UiPath. All rights reserved.