How to run 3rd party tool

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++.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Claudiu
Posts: 32
Joined: Fri Aug 07, 2009 10:16 am

How to run 3rd party tool

Post by Claudiu » Mon Mar 29, 2010 2:44 pm

Hi,

I have the scripting interface installed, I even setup a vbs file that runs 2 macros one after another and next i need to run a 3rd party tool like ccleaner.exe

my vbs is setup for firefox ..

i've found a link about the 3rd party tool implementation, but still i'm getting error when running the vbs file with the below lines for 3rd party tool

Code: Select all

 'Call 3rd party tool
 Set objShell = CreateObject("WScript.Shell")
 iErrorCode = objShell.Run "C:\Program Files\CCleaner\CCleaner.exe"
the whole vbs file that runs the imacros and exe is below .. for testing purposes i've place the exe command line before the imacros scripts

Code: Select all

 set iim1= CreateObject ("iMacros")
 i = iim1.iimInit ("-fx", false)
 if i<0 then
   msgbox "Could not connect to a FIREFOX web browser."
 end if
 'Call 3rd party tool
 Set objShell = CreateObject("WScript.Shell")
 iErrorCode = objShell.Run "C:\Program Files\CCleaner\CCleaner.exe /cmd1 /cmd2"
 i = iim1.iimPlay("Demo-Frame")
 i = iim1.iimPlay("demo-google")
  
 if i<0 then
   s = iim1.iimGetLastError()
   msgbox "The Scripting Interface returned error code: "+cstr(i)
 end if
the following error i get when running the vbs file

Code: Select all

Line: 9
Char: 28
Error: Expected end of statement
Code: 800A0401
Source: Microsoft VBScript compilation error
i'd really appreciate some help on this ..
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to run 3rd party tool

Post by Daniel, Tech Support » Tue Mar 30, 2010 11:00 am

Hello,

This is a Visual Basic related question, which is better to be asked on a relevant forum, but in this particular case simply edit the objShell.Run call to:

Code: Select all

iErrorCode = objShell.Run("C:\Program Files\CCleaner\CCleaner.exe /cmd1 /cmd2")
Best regards,
Daniel, iOpus Support
Claudiu
Posts: 32
Joined: Fri Aug 07, 2009 10:16 am

Re: How to run 3rd party tool

Post by Claudiu » Wed Mar 31, 2010 12:55 pm

ty daniel for answering .. if you look at the code from the first post you'll see i've added that line and you'll also see the error i got ..
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to run 3rd party tool

Post by Daniel, Tech Support » Thu Apr 01, 2010 9:07 pm

Hi,

It was all about the formatting! Your line didn't work me either, so I edited it and it worked. Please try what I posted - there is a little difference.

Best regards,
Daniel, iOpus Support
Claudiu
Posts: 32
Joined: Fri Aug 07, 2009 10:16 am

Re: How to run 3rd party tool

Post by Claudiu » Fri Apr 16, 2010 9:52 am

Daniel, iOpus wrote:Hi,

It was all about the formatting! Your line didn't work me either, so I edited it and it worked. Please try what I posted - there is a little difference.

Best regards,
yep .. working flawlesly .. ty very much ..

best regards
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to run 3rd party tool

Post by Daniel, Tech Support » Fri Apr 16, 2010 1:36 pm

You're welcome! :)
Daniel, iOpus Support
Komak57
Posts: 9
Joined: Sat Jan 10, 2009 10:40 pm

Re: How to run 3rd party tool

Post by Komak57 » Thu May 05, 2011 5:18 am

On a similar note, I'm trying to make a 3rd party "script" in c++ (raw console) in order to strip an image URL of 2 values, and convert them to an integer. The site I'm ripping contains a web link like http://[some-static-site]/in=aha&l=3&[other static info]. aha (length 3) returns an image printing the number 101.

[]&in=atqregixh&l=9[] = 124567890
*Note: l=* returns the length of the number, and all letters are static, as they are not securely encrypted

Rather than my original method of ripping data (custom web page running custom java-script code), I'm trying to use the new function to run a self-designed command to convert the image to an integer so i can handle the info accordingly.

Current (completed) C++ Code *EDIT: unfinished to completed

Code: Select all

#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
using namespace std;
struct list {
	string letter;
	int value;
};
list encr[10] = {
	{ "a", 1 }, 
	{ "t", 2 }, 
	{ "y", 2 }, // Yes, that's right, 2 2's and no 3's
	{ "q", 4 }, 
	{ "r", 5 }, 
	{ "e", 6 }, 
	{ "g", 7 }, 
	{ "i", 8 }, 
	{ "x", 9 }, 
	{ "h", 0 }
};
int main (int argsc, char* argsv[])
{
	// Make sure we're only dealing with the command and the link...
	if (argsc == 2) {
		int val = 0; // Reset our number (just in case)
		string link = argsv[1]; // Set our link for variable-friendly naming
		
		// find the cursor points in the link
		int start = (link.find("?in=")+4); // find() is the shortest method to locating
		int end = link.find("&l=",start);  //  our variable-length string

		// find our fail encrypted text segment
		string encrypted = link.substr(start,(end - start));
		int length = atoi(link.substr(end+3,1).c_str());
		// Lets print the stuff for fun?
		cout << "Encrypted String = " << encrypted << " (" << length << ");" << endl;
		for ( int i = 0; i < length; i++) { // once for every character in the encrypted string
			for ( int c = 0; c < 10; c++) { // once for every character in our table
				if (encr[c].letter == encrypted.substr(i,1)) { // We found it!
					// conversion formula = 
					//    value = value + (number * (10 ^ ((length - digit) - 1)))
					double dval = pow(double(10),(length-(i+1))); //pow() only deals in doubles
					int ival = encr[c].value * (int(dval)); // we want an integer
					val += ival;
					break; // save us some loop trouble
				}
			}
		}
		if (val < 200) { // value isn't worth the effort
			cout << val << " isn't worth it..." << endl;
		} else if (val < 1000) { // value is worth the effort
			cout << val << " will work..." << endl;	
		} else { // omg thats a sexy number
			cout << val << "? DO IT!!!" << endl;
		}
		return val; // make our return and lets get outta here
	} else { // yo, think your script is bugged...
		return 0; // errors return a value of 0
	}
}
*Note: Returns 0 if you entered an invalid quantity of arguments (maybe script error?), or the number that the image would show.

Running "C:\ConvertImg.exe" with arg1 being the link, how can I obtain and handle the return value?
> Reading further into it, I think using the Run() command to execute my app only works for java-script or vb-script web documents... If that's so, i might as well rebuild all of this in java-script like i use to?
Last edited by Komak57 on Thu May 05, 2011 7:43 am, edited 1 time in total.
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: How to run 3rd party tool

Post by MattBell7 » Thu May 05, 2011 7:39 am

this doesn't seem to be imacro related???

are you trying to parse the contents of the image URL to pick out 2 values?

post a couple of sample URLs (blank out the webpage if you want, but leave the parameters as they are) highlighting exactly which values you want to extract
Komak57
Posts: 9
Joined: Sat Jan 10, 2009 10:40 pm

Re: How to run 3rd party tool

Post by Komak57 » Thu May 05, 2011 7:51 am

Actually, its to a pointless facebook game that barely anyone plays. All you do each day is attack a random bunch of people to steal small bits of money (more money if they have more money) and buy stats to attack or defend better. The iMacros script I'm designing is supposed to read the list of available opponents, register their DEF and Money values, and pick the best target... if all available targets are broke, then just refresh the page.

The said project i worked on before was a very advanced script compilation for Mafia Wars.

basic function:
SET ATT
loop for each opponent
SET DEF
SET SILVER_LINK
SET LINK
if ATT > DEF then
run link stripper for monetary value
if MONEY > OLDMONEY then
OLDLINK = LINK
end
end
next

But apparently the Run() function works in VBS with the iMacro external library (or whatever language one pleases). Not sure this is relevant anymore.

EDIT:
iMacro site example: http://wiki.imacros.net/Web_Testing
Subsection: Q: How to invoke 3rd party tools from iMacros?
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: How to run 3rd party tool

Post by MattBell7 » Thu May 05, 2011 7:59 am

iMacros itself, cannot trigger a different application (unless that application is executed from a webpage.

however you can use the scripting interface, to run imacros, and then manipulate the results to be re-used.

http://wiki.imacros.net/Web_Scripting
Komak57
Posts: 9
Joined: Sat Jan 10, 2009 10:40 pm

Re: How to run 3rd party tool

Post by Komak57 » Thu May 05, 2011 8:05 am

Right... that's essentially what i did with java-script before. I just thought it might be a new function and looked into it (though i can imagine the possible security risks in adding such a function). But yeah, i guess i'll just go back to building a java-script page i can run on tab[2] to manipulate all the data required for if-then-else statements (as well as string.sub() functions)
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: How to run 3rd party tool

Post by MattBell7 » Thu May 05, 2011 9:46 am

you don't have to have a separate page, you can script in just about any language, then use the scripting interface to control the browser with your macros, and have your code manipulate it, i've done this with JS, Java, VBS, VBA, C++, and theres a whole list of other languages you can do it in, these languages will let you do whatever else you need to do, such as calling web services, manipulating strings, accessing databases etc.
Komak57
Posts: 9
Joined: Sat Jan 10, 2009 10:40 pm

Re: How to run 3rd party tool

Post by Komak57 » Fri May 06, 2011 1:05 am

The biggest problem is handling all the variables. In most of these Mafia Wars re-builds and scratch designs, theres a lot of values you have to pay attention to. Sure, I can do an iMacro script for each actual function (one for attacking, one for buying, etc), but I could just make a master script that does it all based on when stamina or turns are available... I don't quite understand how to handle the variables extracted through an iMacro script in an external Javascript file.
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: How to run 3rd party tool

Post by MattBell7 » Fri May 06, 2011 7:38 am

value from js to macro:
.js
iimSet("varname", "var value")
.iim
TAG POS=1 TYPE=TEXTAREA CONTENT={{varname}}

value from macro to js:
.iim
TAG POS=1 TYPE=TEXTAREA EXTRACT=TXT
.js
s = iimGetLastExtract()

youre script can then do all the logic based on a few extracts, deciding what to do. Surely though, having a script to do everything for you is boring as hell, its a game after all, they're supposed to be 'played'...
Komak57
Posts: 9
Joined: Sat Jan 10, 2009 10:40 pm

Re: How to run 3rd party tool

Post by Komak57 » Fri May 06, 2011 11:58 pm

built-in Javascript is working pretty well so far. Need to figure out a way to target a specific item based on text givin which occursion it is...

Click First Fight Button
TAG POS=1 TYPE=A ATTR=TXT:FIGHT

Click Next Fight Button
TAG POS=R1 TYPE=A ATTR=TXT:FIGHT

the POS i want to click is in Javascript, whats the best method to hit, say, var Enemy = 3; ?
~edit~
seem to be having some difficulty with the following line:

Code: Select all

iimPlay("CODE:TAG POS=" + Enemy + " TYPE=A ATTR=TXT:FIGHT");
Using it alone in an IIM works fine when i enter POS=6 or what not, but it timing out when i try to do it through Javascript?
Post Reply