Finding an Element

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:


Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Finding an Element

by ramhanuman on Wed Jan 08, 2014 6:44 pm

I'm writing a C++ script with iMacro and basically I want to go login to a website, go to a particular page and look for an element. Under normal circumstances the element won't be there, but the script will continuously refresh the page until the element shows up in which case it will stop refreshing and select it. The element is a checkbox.

I've already written all the code to do most of what I said but I just don't know how to find an element. I already know the element is this:
Code: Select all

So in my C++ I want something like this:
Code: Select all
if (element)
   //if checkbox exist then select it
   //if checkbox does not exist then refresh the page

Is there an iMacro function that allows me to SEARCH for an element and return true of false? Or something that is similar.

I've found this and modified it to fit my code a little so this is what I have:
Code: Select all
int timeout = 60;
ref class ManagedGlobals {
   static iMacros::AppClass^ app;

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 CONTENT=YES", 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;

The stat variable is returning error -1100. Which according to this means
Load Failed: Failed to load the macro (syntax or I/O error) (Found wrong macro command while loading file).

Does anyone know what that means?
Posts: 1
Joined: Wed Jan 08, 2014 5:39 pm

Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 3 guests