2014-01-09 90 views
0

我正在编写C++ iMacro脚本,该脚本将登录到网站,转到特定页面并查找复选框。如果复选框不存在,那么该脚本将每隔X秒刷新页面。如果复选框确实存在,那么它会选择它。基本上我只需要弄清楚如何让iMacro搜索复选框。这里是我到目前为止的代码: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).

任何人都知道问题是什么?

回答

1

尝试删除此零件。

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用于分割命令行。