CPP Tutorial

From iMacros
Jump to: navigation, search

Here's how to use the Scripting Interface with Visual C++ 2008.

Create Project

  • Create a new CLR project (it can be a CLR Empty Project)
    NewProject.png

Add a reference to iMacros Scripting Interface

  • Open the Project Property Pages
  • Choose Framework and References. Click the button Add New Reference...
    AddNewReference.png
  • In the Add Reference window, click on the COM tab and scroll down until you find iMacros Scripting Interface.
    AddReference.png
  • Click the OK button. And OK again to leave the Property Pages window.

Input some code

  • Now you can add a source code file,
    AddSource.png
  • where, as usual you type your code in, for instance:
using namespace System;
int main(array<System::String ^> ^args)
{
   int timeout = 60;
   iMacros::AppClass^ app = gcnew iMacros::AppClass();
   Console::WriteLine("Hello iMacros world!");
   Console::Write("iMacros version ");
   Console::WriteLine(Convert::ToString(app->iimGetInterfaceVersion()));
   app->iimInit("",true,"","","",timeout);
   app->iimDisplay("C++ test",timeout);
   app->iimPlay("CODE:URL GOTO=http://www.iopus.com",timeout);
   app->iimPlay("CODE:WAIT SECONDS=5",timeout);
   app->iimExit(timeout);
   return 0;
}

Done

  • Notice that the intellisense for iMacros class and methods is now activated.
    Intellisense.png
  • Now you can build and run the program as usual.