我正在编写一个 C++ iMacro 脚本,它将登录到一个网站,转到一个特定的页面,然后寻找一个复选框。如果该复选框不存在,则脚本将每 X 秒刷新一次页面。如果该复选框确实存在,那么它将选中它。基本上我只需要弄清楚如何让 iMacro 搜索复选框。到目前为止,这是我的代码:
using namespace System;
#include <string>
int timeout = 60;
ref class ManagedGlobals {
public:
static iMacros::AppClass^ app;
};
// test if element exists
bool doesElementExist() {
iMacros::Status stat;
ManagedGlobals::app->iimDisplay("Searching for element", timeout);
stat = ManagedGlobals::app->iimPlay("CODE:SET !TIMEOUT_TAG 1\n"
+ "CODE:TAG POS=8 TYPE=INPUT:CHECKBOX FORM=ACTION:/pls/PROD/bwykfreg.P_AltPin1?deviceType=C ATTR=NAME:sel_crn EXTRACT=TXT", timeout);
ManagedGlobals::app->iimDisplay(stat.ToString(), timeout);
ManagedGlobals::app->iimPlay("CODE:WAIT SECONDS=10", timeout);
if (stat != iMacros::Status::sOk) {
ManagedGlobals::app->iimDisplay("Didn't find it", timeout);
return false;
}
ManagedGlobals::app->iimDisplay("Found it", timeout);
return true;
}
我已经在页面上对此进行了测试,复选框确实存在,但脚本无法找到它,而是返回错误代码 -1100,根据 this page这意味着 Load Failed: Failed to load the macro (syntax or I/O error) (Found wrong macro command while loading file).
有人知道问题出在哪里吗?
最佳答案
尝试删除这部分。
FORM=ACTION:/pls/PROD/bwykfreg.P_AltPin1?deviceType=C
这部分可以在页面上更改,但不需要 TAG 来查找元素。还尝试通过更改 POS=8 来更改复选框的位置。从数字 1 到 15,看看这个数字是否也发生了变化。
你可能还想改变这个
stat = ManagedGlobals::app->iimPlay("CODE:SET !TIMEOUT_TAG 1\n"
+ "CODE:TAG POS=8 TYPE=INPUT:CHECKBOX FORM=ACTION:/pls/PROD/bwykfreg.P_AltPin1?deviceType=C ATTR=NAME:sel_crn EXTRACT=TXT", timeout);
进入这个
stat = ManagedGlobals::app->iimPlay("CODE:SET !TIMEOUT_TAG 1\n"
+ "TAG POS=8 TYPE=INPUT:CHECKBOX ATTR=NAME:sel_crn EXTRACT=TXT", timeout);
CODE:在一个宏中只能出现一次。 \n
用于分割命令行。
关于c++ - iMacro 查找元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21024215/