How to invoke js file from iim macro?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
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
Post Reply
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

How to invoke js file from iim macro?

Post by azbob » Sun Jan 10, 2021 11:58 pm

Microsoft Windows 10 Home
iMacros Browser (x86) version 12.6.505.4525
Licensed Product: iMacros Enterprise Edition

Win 10, FF72, imacros for ffV10

Converted my files(10 or so) that I use for web scraping to use the scripting interface now they are .js ext.
Trying to call them from .iim files so I can call them from FF sidebar aka pre FF webextensions.
BTW: Connect_to_FF.js works when call through either HTML or Windows Scripting Host
I have tried":

URL GOTO=imacros://run/?m=your-javascript.js " web page cannot be displayed 'address not understood"
iimPlay("CODE:URL GOTO=imacros://run/?m=recaptcha.js"); "SyntaxError: can not parse macro line 7:"
URL GOTO=javasript:connect_to_FF.js " web page cannot be displayed 'address not understood"

Code: Select all

 Call_js_from_iim.iim
VERSION BUILD=12.6.505.4525
TAB T=1     
TAB CLOSEALLOTHERS 
SET !ERRORIGNORE YES
URL GOTO=imacros://run/?m=connect-to_FF.js
'URL GOTO=javasript:connect_to_FF.js'
'iimPlay("CODE:URL GOTO=imacros://run/?m=connect-to_FF.js");

Code: Select all

  Connect_to_FF.js[
var WshShell = WScript.CreateObject("WScript.Shell");
var iim1 = WScript.CreateObject("iMacros");
var iret;


//iret = iim1.iimOpen("-fx", false); //Use open Firefox instance if available
iret = iim1.iimOpen("-fx -fxProfile default-1", true, 60); 
if (iret < 0)
{
	alert("Could not connect to a FIREFOX web browser.");
}

iret = iim1.iimPlay ("C:\\Users\\Public\\Documents\\iMacros\\Macros\\JS files_site\\RLBTEST2.iim");
//iret = iim1.iimPlay("++++SFD.REV1.js", 60);
//iret = iim1.iimPlay("++++STEP_1T_PROMPT_ADDRESS.iim", 60);

if (iret < 0)
{
	var s = iim1.iimGetErrorText();
	alert("The Scripting Interface returned error code: " + iret + "\n" + s);
}

alert("Press OK to close Firefox");

iret = iim1.iimClose();

WScript.Quit(iret)

function alert(msg)
{
	WshShell.Popup(msg);
}

Code: Select all

  RLBTEST2.iim
VERSION BUILD=12.6.505.4525
TAB T=1     
TAB CLOSEALLOTHERS 
SET !ERRORIGNORE YES
URL GOTO=https://www.youtube.com/
''************PROMPT FOR ADDRESS*********************
PROMPT "The js Call from iim TEST Worked" 
Thanks
Last edited by azbob on Mon Jan 11, 2021 3:19 pm, edited 1 time in total.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to invoke js file from iim macro

Post by chivracq » Mon Jan 11, 2021 7:28 am

azbob wrote:
Sun Jan 10, 2021 11:58 pm

Code: Select all

Microsoft Windows 10 Home
iMacros Browser (x86) version 12.6.505.4525
Licensed Product: iMacros Enterprise Edition
-----------------------------------------------------------------------------------------
iMacros extension 10.1.0
------------------------------------------------------------------------------------------
Mozilla Firefox (x64) version 55.0 (x64 en-US)
Firefox profile "FFV55-2" iMacros extension 8.9.7
Firefox profile "default-release-1" iMacros extension 10.0.2.1450
------------------------------------------------------------------------------------------
iMacros File Access version 10.1.0.1465
Converted my files(10 or so) that I use for web scraping to use the scripting interface now they are .js ext.
Trying to call them from .iim files so I can call them from FF sidebar aka pre FF webextensions.
BTW: Connect_to_FF.js works when call through either HTML or Windows Scripting Host
I have tried":

URL GOTO=imacros://run/?m=your-javascript.js " web page cannot be displayed 'address not understood"
iimPlay("CODE:URL GOTO=imacros://run/?m=recaptcha.js"); "SyntaxError: can not parse macro line 7:"
URL GOTO=javasript:connect_to_FF.js " web page cannot be displayed 'address not understood"

Code: Select all

 Call_js_from_iim.iim
VERSION BUILD=12.6.505.4525
TAB T=1     
TAB CLOSEALLOTHERS 
SET !ERRORIGNORE YES
URL GOTO=imacros://run/?m=connect-to_FF.js
'URL GOTO=javasript:connect_to_FF.js'
'iimPlay("CODE:URL GOTO=imacros://run/?m=connect-to_FF.js");

Code: Select all

  Connect_to_FF.js[
var WshShell = WScript.CreateObject("WScript.Shell");
var iim1 = WScript.CreateObject("iMacros");
var iret;


//iret = iim1.iimOpen("-fx", false); //Use open Firefox instance if available
iret = iim1.iimOpen("-fx -fxProfile default-1", true, 60); 
if (iret < 0)
{
	alert("Could not connect to a FIREFOX web browser.");
}

iret = iim1.iimPlay ("C:\\Users\\Public\\Documents\\iMacros\\Macros\\JS files_site\\RLBTEST2.iim");
//iret = iim1.iimPlay("++++SFD.REV1.js", 60);
//iret = iim1.iimPlay("++++STEP_1T_PROMPT_ADDRESS.iim", 60);

if (iret < 0)
{
	var s = iim1.iimGetErrorText();
	alert("The Scripting Interface returned error code: " + iret + "\n" + s);
}

alert("Press OK to close Firefox");

iret = iim1.iimClose();

WScript.Quit(iret)

function alert(msg)
{
	WshShell.Popup(msg);
}

Code: Select all

  RLBTEST2.iim
VERSION BUILD=12.6.505.4525
TAB T=1     
TAB CLOSEALLOTHERS 
SET !ERRORIGNORE YES
URL GOTO=https://www.youtube.com/
''************PROMPT FOR ADDRESS*********************
PROMPT "The js Call from iim TEST Worked" 
Thanks

Oh...!?, I thought you were sharing a 'HowTo' from your Thread Title... :? , => add a Qt Mark if you are looking for Help (and want me to read your OP)... :idea:

And hum..., nearly "too much Info" in your FCI, but I see "prominently" some "v10.1.0" which is a CR Version, but '.js' Scripts have never been supported on CR, hum and same with iMB v12.6 (or any Version actually) that I see in your '.iim' Script...

'.js' Scripts are only supported until v9.0.3 for FF (recommended v8.9.7 for FF) => on FF and only on FF, no other Browser(s) support(s) iMacros '.js' Scripts... (And both v9.0.3 + v8.9.7 only work until FF56, recommended = FF v55.0.3, or PM28 or Basilisk/WaterFox v2019/2020...)

=> So you may want to mention from which Browser/FCI you want to launch a '.js' Script...? :idea:
(Maybe you did, but I didn't "really" read your OP (yet) because of the 'HowTo' + Qt Mark, ah-ah...! :oops: )

>>>

Oh...!?, and my Qt Mark "Remark" also applies to your other Thread opened in the 'Scripting Interface' Sub-Forum if you are not sharing "another" 'HowTo', ah-ah...! :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to invoke js file from iim macro?

Post by chivracq » Mon Jan 11, 2021 6:54 pm

Alright, Thanks for the Qt Mark in the Thread Title, and I see that you've "simplified" your FCI...:
azbob wrote:
Sun Jan 10, 2021 11:58 pm

Code: Select all

Microsoft Windows 10 Home
iMacros Browser (x86) version 12.6.505.4525
Licensed Product: iMacros Enterprise Edition

Code: Select all

Win 10, FF72, imacros for ffV10

=> v10.0.2 for FF + FF72, and now removed, but you had mentioned that you had installed the FIO-Module for File Access, which is needed for the 'SI' (Scripting Interface) to communicate with FF/CR etc... (Hum, and I didn't know a "new" v10.1.0 Version had been released with iMacros v10.1.0 for CR... OK...)

Then well, the Syntax you have in your first (the '.iim') Script is correct, to call/launch a '.js' Script (or another '.iim' Script) from an '.iim' Script:

Code: Select all

URL GOTO=imacros://run/?m=connect-to_FF.js
BUT...!, that Syntax is not supported anymore (or yet?) in v10.0.2 for FF (even to call another '.iim' Script), and '.js' Scripts are not supported at all in v10.0.2 for FF...! :(
(it's documented in the Wiki in the Releases Notes for v10.0.2 for FF.)

=> You would have to use v8.9.7 for FF for this "Construction" to work, with one of the Browsers I mentioned, if you want to use '.js' Scripts anyway...

Calling a '.js' Script (or '.vbs' or '.ps' or whatever) from an '.iim' Script is a bit cumbersome anyway in my Opinion, it "should" be the other way around, with your '.js' or '.vbs' of '.ps' Script being the "main" Script containing the "Logic" and directing the Workflow of the Scenario for your Web-Automation...

Even if I can "think" of a few Usecases where this Approach/Func could be useful, for example, I do all my Automation in pure '.iim', (using v8.8.2 for FF + v8.9.7 for FF), and yep indeed in a few "Places", I call (or I was calling) some mini '.js' Script only to be able to use 'iimDisplay()' which is not supported in pure '.iim' and I never found a "real" IRT Workaround offering the same Func like 'iimDisplay()'. But it has its "Drawbacks" as the whole Logic needs to be split into several Scripts, as the '.js' Script then needs to call a 2nd '.iim' Script, which doesn't know anything about the first '.iim', so all Vars have been "lost"..., and you need a specific/separate '.js' Script each time, so hum..., I "usually" consider this Approach/Implementation "Bad Practice"...

I have the "Feeling" your whole Implementation is a bit complex/cumbersome, can't you do your whole Automation in pure '.iim', if it's for Web-Scraping...? :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: How to invoke js file from iim macro?

Post by azbob » Mon Jan 11, 2021 7:45 pm

Legacy work config was FF49 and im for FF 8.9.7, now FF55(forced by vendor site change) and 8.9.7. Use to Extract info from couple of sites than form fill into another.

Need to use js to find the correct frame number in order to extract from site that uses dynamic frames.
I also create alot of csv files for my form fill macros that make use of the orphaned FILEDELETE command.

So I have been messing around/testing with the Scripting interface, FF55, FF72, IE, CR and now PM to insure I won't get left behind.
Concerns in migrating to Scripting interface and API:
1) Not being able to call js macros from convenience of a "sidebar". Hence the hiding the js in iim file with "URL GOTO=imacros://run/?m=connect-to_FF.js"
2) How to handle the "FILEDELTE" issue. Working on it, but it would mean another js script. ugh
3) FF72+ (One vendors only supports FF) persistent pop ups and general quirkiness. Hence PM interest and can I use with scripting interface/API.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to invoke js file from iim macro?

Post by chivracq » Mon Jan 11, 2021 8:04 pm

azbob wrote:
Mon Jan 11, 2021 7:45 pm
Legacy work config was FF49 and im for FF 8.9.7, now FF55(forced by vendor site change) and 8.9.7. Use to Extract info from couple of sites than form fill into another.

Need to use js to find the correct frame number in order to extract from site that uses dynamic frames.
I also create alot of csv files for my form fill macros that make use of the orphaned FILEDELETE command.

So I have been messing around/testing with the Scripting interface, FF55, FF72, IE, CR and now PM to insure I won't get left behind.
Concerns in migrating to Scripting interface and API:
1) Not being able to call js macros from convenience of a "sidebar". Hence the hiding the js in iim file with "URL GOTO=imacros://run/?m=connect-to_FF.js"
2) How to handle the "FILEDELTE" issue. Working on it, but it would mean another js script. ugh
3) FF72+ (One vendors only supports FF) persistent pop ups and general quirkiness. Hence PM interest and can I use with scripting interface/API.

Alright, if you were using v8.9.7 for FF + FF49, everything should work the same with v8.9.7 for FF + FF55, if you didn't update iMB/'SI' to v12.6 in that "Process", you were probably at v10.3 or v11.5, I reckon...

The only Difference between both FCI's is the 'FILTER' Command that got broken from FF51 or FF52 (by Mozilla), when used on "large" Pages with 1000+ Images.
Oh yeah!, and "somewhere" between FF49 and FF55, the Behaviour with Multiple Logins on a same Site/Page had changed, but could "easily" be handled with 2 Settings in 'about:config'...

>>>
1) Not being able to call js macros from convenience of a "sidebar". Hence the hiding the js in iim file with "URL GOTO=imacros://run/?m=connect-to_FF.js"

Hum, launching a '.js' Script from the iMacros Sidebar should be exactly the same in FF55 and FF49, with the same v8.9.7 for FF Add-on. :o

>>>
2) How to handle the "FILEDELTE" issue. Working on it, but it would mean another js script. ugh

Yep, "known" Behaviour, you get some Runtime Error if the File does not exist (yet), simply handled with an '!ERRORIGNORE' (="YES") before the 'FILEDELETE'. :idea:

>>>
3) FF72+ (One vendors only supports FF) persistent pop ups and general quirkiness. Hence PM interest and can I use with scripting interface/API.

Well, with FF72, you'll/'d have to use v10.0.2 for FF, which is very limited (and buggy!) indeed..., and doesn't support '.js' Scripts anyway/also...
=> Yep-yep, v8.9.7 for FF + PM28 is a "perfect" Alternative indeed.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: How to invoke js file from iim macro?

Post by azbob » Mon Jan 11, 2021 8:41 pm

My recent questions have been about what will I have to change/deal with if I migrate to SI and im for FF v10.
Hum, launching a '.js' Script from the iMacros Sidebar should be exactly the same in FF55 and FF49, with the same v8.9.7 for FF Add-on. :o
I meant when using SI...js files don't show up in sidebar FF56+ requires im for ff v10. Hence wanted to find a way to sneak them into sidebar under cover of .iim
Yep, "known" Behaviour, you get some Runtime Error if the File does not exist (yet), simply handled with an '!ERRORIGNORE' (="YES") before the 'FILEDELETE'
Meant when using SI and im for ff v10
This refers to FILEDELETE overwrite stopped working in im for FF v9 (viewtopic.php?t=26562#p70405 Has it error been fixed?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to invoke js file from iim macro?

Post by chivracq » Tue Jan 12, 2021 12:21 am

azbob wrote:
Mon Jan 11, 2021 8:41 pm
My recent questions have been about what will I have to change/deal with if I migrate to SI and im for FF v10.
Hum, launching a '.js' Script from the iMacros Sidebar should be exactly the same in FF55 and FF49, with the same v8.9.7 for FF Add-on. :o
I meant when using SI...js files don't show up in sidebar FF56+ requires im for ff v10. Hence wanted to find a way to sneak them into sidebar under cover of .iim

Hum, you didn't mention iMB + SI Version you "currently" use, and from which you "consider" migrating to v12.6,,,(?)

But yep, once using iMB/SI v12.6, on FF, you'll have to use iMacros for FF v10.0.2, which indeed only works on FF56+, with "current" Version being now at FF84 (January 2021).
And v10.0.2 for FF doesn't support at all '.js' Scripts. (Not related to SI.)

v10.0.2 for FF is already 2.5 years old (released in July 2018), no Info if some "new" Version will soon/one day/ever be released for FF, iMacros for CR v10.x already had several new Versions released since, + iMB v12.6 got also released in that time, and I "think" I understood from @TechSup that @Dev was working on some new Version for iMB (v13...?), which actually would be a completely new Browser, forked on 'Chromium' like 'Chrome', so I guess nothing is really "happening" at the moment concerning iMacros for FF...

No Info about the Specs and Func covered/offered by this new iMB v13 Version/Browser, I don't know, but maybe Support for '.js' Scripts is in the Planning... (I have no Idea, just day-dreaming, ah-ah...! :P )

>>>
azbob wrote:
Mon Jan 11, 2021 8:41 pm
Yep, "known" Behaviour, you get some Runtime Error if the File does not exist (yet), simply handled with an '!ERRORIGNORE' (="YES") before the 'FILEDELETE'
Meant when using SI and im for ff v10
This refers to FILEDELETE overwrite stopped working in im for FF v9 (viewtopic.php?t=26562#p70405 Has it error been fixed?

Oh yep indeed, this is "different" than what I meant, ah-ah...! :wink:

Hum, alright, I remember this Thread indeed, after reading it again, hum 2016 already, ah-ah...! :shock: :wink:
=> "Has this Error been fixed?" => Well, @TechSup didn't post anymore in that Thread, so I guess nothing happened concerning that Command, but this Bug or Limitation you had encountered was only specific to v9.0.3 (v8.9.7 was not impacted), and "since", only v10.0.2 for FF got released, ... which doesn't support 'FILEDELETE' at all, ah-ah...! :mrgreen:

And even on v9.0.3 for FF, I had provided an Explanation of the "complete" Behaviour, leading to some easy Workaround... 8)
I actually noticed (and corrected) some little Mistake, in that/one Post of mine in that Thread... :oops:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: How to invoke js file from iim macro?

Post by azbob » Tue Jan 12, 2021 3:57 am

Well I guess the best path is to stay with im v12 and 8.9.7 on either PM- as this looks promising but just started using or FF55 and forget SI in less I'm forced to change as it is too cumbersome!

Thanks for all your help
Post Reply