I'm writing a C++ iMacro script that will login to a website, go to a particular page, and look for a checkbox. If the checkbox does not exist then the script will refresh the page every X seconds. If the checkbox does exist then it will select it. Basically I just to need figure out how to get iMacro to search for the checkbox. Here's my code so far:

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;
}

I've tested this out on the page, the checkbox DOES exist but the script is unable to find it and instead returns error code -1100 which according to this page it means Load Failed: Failed to load the macro (syntax or I/O error) (Found wrong macro command while loading file).

Anyone know what the problem is?

有帮助吗?

解决方案

Try to remove this part.

FORM=ACTION:/pls/PROD/bwykfreg.P_AltPin1?deviceType=C

This part can be changeable on the page but it's not needed for TAG to find the element. Also try to change position of checkbox by changing POS=8 . Start from number 1 to 15 and see does that number change too.

Also you might want to change this

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);

into this

stat = ManagedGlobals::app->iimPlay("CODE:SET !TIMEOUT_TAG 1\n"
        + "TAG POS=8 TYPE=INPUT:CHECKBOX ATTR=NAME:sel_crn EXTRACT=TXT", timeout);

CODE: can appear only once inside one macro. \n is used to split command lines.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top