Run multiple javascript code for imacros inside a javascript file (iim, js)

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
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:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

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.
Post Reply
provoquestosito
Posts: 54
Joined: Sat Jan 30, 2010 12:43 am

Run multiple javascript code for imacros inside a javascript file (iim, js)

Post by provoquestosito » Thu Jan 17, 2019 1:03 am

I have Windows 7, Firefox 56, Imacros 8.9.7

I need to run multiple imacros javascript code in sequence one after the other.

With iim imacros extension I can use this command inside the javascript macro starter

Example run_all_macro.js

iimPlay("macro1.iim")
iimPlay("macro2.iim")
iimPlay("macro3.iim")
iimPlay("macro4.iim")

I need to run macro in javascript format and this code do not works

Example run_all_macro.js

iimPlay("macro1.js")
iimPlay("macro2.js")
iimPlay("macro3.js")
iimPlay("macro4.js")

Example of macro1.js

var imacros = "PROXY ADDRESS=12.3.4.5:67" + "\n";
imacros += "URL GOTO=javascript:{document.getElemensByClassName('class_here')[0].click();undefined;}" + "\n";
iimPlayCode(imacros);

How can i run multiple javascript code inside a javascript code ?
chivracq
Posts: 8052
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Run multiple javascript code for imacros inside a javascript file (iim, js)

Post by chivracq » Thu Jan 17, 2019 1:51 am

provoquestosito wrote:
Thu Jan 17, 2019 1:03 am
I have

Code: Select all

Windows 7, Firefox 56, Imacros 8.9.7 
I need to run multiple imacros javascript code in sequence one after the other.

With iim imacros extension I can use this command inside the javascript macro starter

Example run_all_macro.js

Code: Select all

    iimPlay("macro1.iim")
    iimPlay("macro2.iim")
    iimPlay("macro3.iim")
    iimPlay("macro4.iim")
I need to run macro in javascript format and this code do not works

Example run_all_macro.js

Code: Select all

    iimPlay("macro1.js")
    iimPlay("macro2.js")
    iimPlay("macro3.js")
    iimPlay("macro4.js")
Example of macro1.js

Code: Select all

    var imacros = "PROXY ADDRESS=12.3.4.5:67" + "\n";
    imacros += "URL GOTO=javascript:{document.getElemensByClassName('class_here')[0].click();undefined;}" + "\n";
    iimPlayCode(imacros);
How can i run multiple javascript code inside a javascript code ?
Documented in the Wiki on the Page for the 'iimPlay()' Command... 8)

+ Parallel Thread on SOF:
- Run multiple javascript code for imacros inside a javascript file (iim, js)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
provoquestosito
Posts: 54
Joined: Sat Jan 30, 2010 12:43 am

Re: Run multiple javascript code for imacros inside a javascript file (iim, js)

Post by provoquestosito » Thu Jan 17, 2019 7:42 pm

Hi chivracq

Thanks for suggestion.

I tryed with some codes but actually do not works, i need to continue to read and try codes.

In my case the javascript load only the first macro and do not load the subsequent macros.

Have a nice day
chivracq
Posts: 8052
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Run multiple javascript code for imacros inside a javascript file (iim, js)

Post by chivracq » Sat Jan 19, 2019 4:24 am

provoquestosito wrote:
Thu Jan 17, 2019 7:42 pm
Hi chivracq

Thanks for suggestion.

I tryed with some codes but actually do not works, i need to continue to read and try codes.

In my case the javascript load only the first macro and do not load the subsequent macros.

Have a nice day
Then I don't know, "Thanks for suggestion." => to read the Wiki..., sounds a bit funny to me, but I won't be doing any Digging in this one as you didn't "really" finish your last/previous Thread "correctly" and useful for the Forum Community and other Users...

And I find this Construction very cumbersome also, to be honest... I don't really understand the "Purpose"... :?
I already find many '.js' Scripts (on the Forum) cumbersome but I can understand that for "Maintenance" Reason it can be handy to have the whole Logic in just 1 single Script, especially if some parts of the Script might be called and reused again in the Script, and for "Modularity" + "Scalability" Reasons, the Script would be "ready" for any (future) additional Conditional Logic, but those Reasons disappear when calling several '.js' Sub-Scripts from 1 other '.js' Script... Ah hum..., unless indeed you reuse some parts in several different Scripts/Scenarios..., or some Scripts might be cross-calling each other, but that would give a pretty complex "Matrix-like" Scenario, but from the kind of Qt's you are asking on the Forum, you don't sound Advanced enough to have developed such a complex Solution, I would think... OK, I don't know, I would need to know the whole "Picture"...

And again, no Script posted..., only Info we get is: "I tryed but not works"
=> Tja, not sure how you expect other Users to troubleshoot and help you with your Pb with that kind of vague Info...!? :roll:

You can try posting in the "other" Thread where TechSup had done some Testing, but you'll need to be a bit more "precise" than "I tryed but not works" if you hope for TechSup to react... :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
provoquestosito
Posts: 54
Joined: Sat Jan 30, 2010 12:43 am

Re: Run multiple javascript code for imacros inside a javascript file (iim, js)

Post by provoquestosito » Tue Jan 22, 2019 11:10 pm

Hi chivracq

Thanks for reply.

I tryed this example:

viewtopic.php?f=11&t=21710&p=54684#p54684

Test.js:

Code: Select all

iimPlayCode("URL GOTO=imacros://run/?m=Test1.js");
iimPlayCode("URL GOTO=imacros://run/?m=Test2.js");
Test1.js:

Code: Select all

iimPlayCode("URL GOTO=http://www.iopus.com/");
Test2.js:

Code: Select all

iimPlayCode("TAB OPEN\nTAB T=2\nURL GOTO=http://www.alertfox.com/");
But run only the 1 macro, after complete test1.js the macro stop to run.

I have not find any solution to solve.

Probably javascript do not allow to run multiple code inside.

Thanks for suggestion

Have a nice day
chivracq
Posts: 8052
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Run multiple javascript code for imacros inside a javascript file (iim, js)

Post by chivracq » Tue Jan 29, 2019 11:46 pm

Posting "on behalf" of a [new] User (well, 1st time Poster, they actually registered in 2017) as I didn't approve their Post as they posted in Vietnamese, asking them to translate their Post into English, but they didn't do so... But their Post looks relevant to me for the Thread... (I let 'GoogleTranslate' translate the Text Part that was in Vietnamese...)
Re: Run multiple javascript code for imacros inside a javascript file (iim, js)
Posted by biaconhieu » 29/01/2019 - 17:01
[Post disapproved for the following Reason: "Post disapproved, as Forum Language is English... => Translate your Post into English... (And the Comments in your Script also maybe...) - (User notified...)"]

hi, I accidentally skimmed that you posted a secret in the place where you run many .js or .iim files
This is the code you can refer to.

Sorry for not using English, because I can't speak! you can hardly translate via google trans: lol:: lol:
run on firefox 56, imacro 8.9.7

Code: Select all

a = "D:\\_0xd001.js";
b = "D:\\_0xd002.js";
c = "#Current.iim";

function readExt(filename) {
return imns.FIO.readTextFile(imns.FIO.openNode(filename));
}

function Call_My_Script() {
a1 = readExt(a);
a2 = readExt(b);
eval(a1); //chạy file _0xd001.js
iimPlay(c); //chạy file #Current.iim
iimPlayCode(`wait seconds=1`);
eval(a2); //chạy file _0xd001.js
}

//số lần cần chạy lại
for (i = 1; i <= 3; i++) {
iimDisplay("số lần đã chạy " + i);
Call_My_Script();
}
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
techimac
Posts: 286
Joined: Fri Feb 20, 2015 9:27 pm

Re: Run multiple javascript code for imacros inside a javascript file (iim, js)

Post by techimac » Sun Feb 17, 2019 11:00 am

Here is the correct syntax
use this

Code: Select all

var Macro = "";
Macro += "CODE:" + "\n";
Macro += "SET !ERRORIGNORE YES" + "\n";
Macro += "SET !TIMEOUT_PAGE 60" + "\n";
Macro += "PROXY ADDRESS=12.3.4.5:67" + "\n";
Macro += "URL GOTO=javascript:{document.getElemensByClassName('class_here')[0].click();undefined;}" + "\n";
iimPlay(Macro)
Post Reply