Launch imacros from terminal using imacros://run/?m=

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
groundfalling
Posts: 46
Joined: Tue Jul 01, 2014 1:26 pm

Launch imacros from terminal using imacros://run/?m=

Post by groundfalling » Sun Sep 09, 2018 8:03 am

Hi,
Currently im using iMacros 10.0.2.1450 + Firefox 61.0.1 + Ubuntu 16.0.4
I have been trying to run the macro with the browser launch from the terminal along by using "imacros://run/?m=Open6Tabs.iim" or "imacros://Demo-Firefox/run/?m=Open6Tabs.iim" but it does not run the macro after the browser is launched.
it was working great until iMacros 8.9.7 + Firefox 55.0.3, is there a different syntax to load the macro from bookmarks in latest imacros for firefox quantum?
I cannot afford to downgrade to older firefox version so would really appreciate if someone could provide solution for this for quantum firefox. Thank you
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Launch imacros from terminal using imacros://run/?m=

Post by chivracq » Sun Sep 09, 2018 2:17 pm

groundfalling wrote:Hi,
Currently im using

Code: Select all

iMacros 10.0.2.1450 + Firefox 61.0.1 + Ubuntu 16.0.4

I have been trying to run the macro with the browser launch from the terminal along by using "imacros://run/?m=Open6Tabs.iim" or "imacros://Demo-Firefox/run/?m=Open6Tabs.iim" but it does not run the macro after the browser is launched.
it was working great until iMacros 8.9.7 + Firefox 55.0.3, is there a different syntax to load the macro from bookmarks in latest imacros for firefox quantum?
I cannot afford to downgrade to older firefox version so would really appreciate if someone could provide solution for this for quantum firefox. Thank you
Yep, the 'imacros://run/?m=' Syntax is not supported anymore in iMacros for FF v10.0.2 (not sure either if it was still working in v9.0.3 btw), and you get some Browser Runtime Error about "the 'imacros' Protocol not being associated with any Application..." I think I remember from some mini-Test during the v10.0.2 Beta-Testing Phase...

The only (a bit cumbersome) Workaround I know of is to embed your Macro as Base64 Encoded Bookmark Macro or on-the-fly String Macro in your own '.html' Page...
Documented in the Wiki: Command Line Support

If "maintaining" a "parallel" Installation with, say, (Portable) FF55 or FF56 (+ iMacros for FF v8.9.7) is not an Option for you, you could have a look at FF Forked Browsers like Pale Moon / Waterfox / Cyberfox / etc on which v8.9.7 or v8.8.7 will still work... :idea:
(I use for myself Pale Moon v26.3.3 (=FF47) + iMacros for FF v8.8.2 (+ Win10_x64).)
- (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: Launch imacros from terminal using imacros://run/?m=

Post by chivracq » Sun Sep 09, 2018 2:29 pm

Hum..., or another "Idea" would be to launch your Macro from an OS-Level Macro with 'AHK' or 'AutoIt' or some equivalent Tool on Ubuntu... :idea:
(But that's still "a bit" cumbersome, 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...
groundfalling
Posts: 46
Joined: Tue Jul 01, 2014 1:26 pm

Re: Launch imacros from terminal using imacros://run/?m=

Post by groundfalling » Sun Sep 09, 2018 4:24 pm

Thank you for your response chivracq,
i was able to run the below code in htm file through terminal, which meant that it is loading the imacros with the browser.

Code: Select all

<html>
   <body onload="window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000);">

      <script>
         var macroCode = '';
         macroCode += 'PROMPT HELLO!\n';
         macroCode += 'URL GOTO=http://imacros.net/\n';
         macroCode += 'PROMPT BYE!\n';

         function launchMacro()
            {
            try
               {
                  if(!/^(?:chrome|https?|file)/.test(location))
                  {
                     alert('iMacros: Open webpage to run a macro.');
                     return;
                  }
			   
                  var macro = {}; 
                  macro.source = macroCode;
                  macro.name = 'EmbeddedMacro';
			   
                  var evt = document.createEvent('CustomEvent');
                  evt.initCustomEvent('iMacrosRunMacro', true, true, macro);
                  window.dispatchEvent(evt);
               }
            catch(e)
            {
               alert('iMacros Bookmarklet error: '+e.toString());
            };
         }
      </script>

      <a id="criimlaunch" href="javascript:launchMacro();">Launch iMacros</a>

   </body>
</html>
But im still confused about how to embed this below macro demo code in the above HTM file so it could run with the launch. Would really appreciate the help. Thank you

Code: Select all

VERSION  BUILD=7500718 RECORDER=FX
TAB T=1  

URL GOTO=http://demo.imacros.net/Automate/Eval
'Wait a random number (1 to 5) of seconds
SET !VAR1 EVAL("Math.floor(Math.random()*5 + 1);")
WAIT SECONDS={{!VAR1}}
SET !EXTRACT_TEST_POPUP NO
'Extract the date
TAG POS=1 TYPE=B ATTR=TXT:* EXTRACT=TXT
'Check if time deviates more than 20 hours. If yes, stop macro with an error
SET !VAR2 EVAL("var n_hours = 20, ms_in_hour = 60*60*1000, s=\"{{!EXTRACT}}\", now = new Date(); var deviation = now.getTime()-Date.parse(s); if (deviation > n_hours*ms_in_hour) MacroError(\"Time deviates more than 20 hours\");")
'Clean the !EXTRACT variable for the next task
SET !EXTRACT NULL
'Extract the number in the input box
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:form1 ATTR=NAME:textfield EXTRACT=TXT
'Check if extracted number (still a string, has to be parsed into a float!) lies between 99 and 101. 
'Stop macro with an error if not.
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\", d = parseFloat(s); if(d > 99 && d < 101) d; else MacroError(\"Value is not in the set range\")")
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Launch imacros from terminal using imacros://run/?m=

Post by chivracq » Sun Sep 09, 2018 4:39 pm

groundfalling wrote:Thank you for your response chivracq,
i was able to run the below code in htm file through terminal, which meant that it is loading the imacros with the browser.

Code: Select all

<html>
   <body onload="window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000);">

      <script>
         var macroCode = '';
         macroCode += 'PROMPT HELLO!\n';
         macroCode += 'URL GOTO=http://imacros.net/\n';
         macroCode += 'PROMPT BYE!\n';

         function launchMacro()
            {
            try
               {
                  if(!/^(?:chrome|https?|file)/.test(location))
                  {
                     alert('iMacros: Open webpage to run a macro.');
                     return;
                  }
			   
                  var macro = {}; 
                  macro.source = macroCode;
                  macro.name = 'EmbeddedMacro';
			   
                  var evt = document.createEvent('CustomEvent');
                  evt.initCustomEvent('iMacrosRunMacro', true, true, macro);
                  window.dispatchEvent(evt);
               }
            catch(e)
            {
               alert('iMacros Bookmarklet error: '+e.toString());
            };
         }
      </script>

      <a id="criimlaunch" href="javascript:launchMacro();">Launch iMacros</a>

   </body>
</html>
But im still confused about how to embed this below macro demo code in the above HTM file so it could run with the launch. Would really appreciate the help. Thank you

Code: Select all

VERSION  BUILD=7500718 RECORDER=FX
TAB T=1  

URL GOTO=http://demo.imacros.net/Automate/Eval
'Wait a random number (1 to 5) of seconds
SET !VAR1 EVAL("Math.floor(Math.random()*5 + 1);")
WAIT SECONDS={{!VAR1}}
SET !EXTRACT_TEST_POPUP NO
'Extract the date
TAG POS=1 TYPE=B ATTR=TXT:* EXTRACT=TXT
'Check if time deviates more than 20 hours. If yes, stop macro with an error
SET !VAR2 EVAL("var n_hours = 20, ms_in_hour = 60*60*1000, s=\"{{!EXTRACT}}\", now = new Date(); var deviation = now.getTime()-Date.parse(s); if (deviation > n_hours*ms_in_hour) MacroError(\"Time deviates more than 20 hours\");")
'Clean the !EXTRACT variable for the next task
SET !EXTRACT NULL
'Extract the number in the input box
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:form1 ATTR=NAME:textfield EXTRACT=TXT
'Check if extracted number (still a string, has to be parsed into a float!) lies between 99 and 101. 
'Stop macro with an error if not.
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\", d = parseFloat(s); if(d > 99 && d < 101) d; else MacroError(\"Value is not in the set range\")")
Yeah..., hum-hum..., I've never "experimented" with "it" either, but I think it will work for "short and simple" Macros, but will quickly become a bit of a "pain in the ass" with a bit more complex Macros, especially with 'EVAL()' Statements indeed, as you'll have to "take care" and to single/double/triple escape all Special Characters like Single + Double Quotes + Escape Char etc... and + the Single Quote for '.iim' Comments as well, ah-ah...! :twisted:

It might be easier in that case if you let iMacros do the "Conversion" itself by using Base64 Bookmark Macros, I would think... Not very practical if you need to regularly edit the Macro, but at least you won't have to worry about converting your Macro... :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...
groundfalling
Posts: 46
Joined: Tue Jul 01, 2014 1:26 pm

Re: Launch imacros from terminal using imacros://run/?m=

Post by groundfalling » Sun Sep 09, 2018 4:48 pm

how about running this simple below code from the HTM file?

Code: Select all

SET !VAR1 1
'Start at TAB T=2, as we do not want to change "start" tab of user
'Open TAB, select it, load website
TAB OPEN NEW
ADD !VAR1 1
TAB T={{!VAR1}}
URL GOTO=http://www.iopus.com
groundfalling
Posts: 46
Joined: Tue Jul 01, 2014 1:26 pm

Re: Launch imacros from terminal using imacros://run/?m=

Post by groundfalling » Sun Sep 09, 2018 4:50 pm

just asking if it has to be converted to a JS first and than added between the <script></script>
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Launch imacros from terminal using imacros://run/?m=

Post by chivracq » Mon Sep 10, 2018 2:49 am

groundfalling wrote:how about running this simple below code from the HTM file?

Code: Select all

SET !VAR1 1
'Start at TAB T=2, as we do not want to change "start" tab of user
'Open TAB, select it, load website
TAB OPEN NEW
ADD !VAR1 1
TAB T={{!VAR1}}
URL GOTO=http://www.iopus.com
groundfalling wrote:just asking if it has to be converted to a JS first and than added between the <script></script>
Hum, OK..., and... any Progress..., 12h later...?

I told you I never "experimented" with those Methods/Techniques (as I never needed them for myself), so..., did you try...?, did you make any Progress...? (Not difficult to test by yourself I would think...) :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...
groundfalling
Posts: 46
Joined: Tue Jul 01, 2014 1:26 pm

Re: Launch imacros from terminal using imacros://run/?m=

Post by groundfalling » Mon Sep 10, 2018 4:14 am

The most important part is the frustration and disappointment which comes with the new imacros version 10.0.2.1450, when you launch the browser through terminal the addon itself fails and disappears most of the time, as if it was never installed and you have have to reinstall it which kills the whole purpose of using it auto through bash or terminal.
Don't know if it is firefox quantum issue or the bug is in the addon itself that it just disappears when the browser launches and the times when it is still there and it manages to run the HTM file than it has so many restrictions. I dont mind paying for the license to remove the restrictions but if the addon will not even install properly and wont load through terminal than no point using it.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Launch imacros from terminal using imacros://run/?m=

Post by chivracq » Mon Sep 10, 2018 5:10 am

groundfalling wrote:The most important part is the frustration and disappointment which comes with the new imacros version 10.0.2.1450, when you launch the browser through terminal the addon itself fails and disappears most of the time, as if it was never installed and you have have to reinstall it which kills the whole purpose of using it auto through bash or terminal.
Don't know if it is firefox quantum issue or the bug is in the addon itself that it just disappears when the browser launches and the times when it is still there and it manages to run the HTM file than it has so many restrictions. I dont mind paying for the license to remove the restrictions but if the addon will not even install properly and wont load through terminal than no point using it.
"The most important part is the frustration and disappointment which comes with the new imacros version 10.0.2.1450..."
=> Yeah, well, I can definitely relate..., v10.0.2 in my Opinion is OK for mini-simplistic Macros only using a few "Standard" Commands...

I was "involved" during the Beta-Testing Phase...., which lasted about 6-8 weeks, with 4 or 5 different Builds I think..., I spent most of the time "fighting" for each time 1-2-3 completely blocking parts (in my Opinion), in the end after those 6-8 weeks, I maybe managed to test (hum..., is a big word) max 10% or 20% of all the Functionality that I use myself.., and suddenly some "next day", v10.0.2 was already officially released and pushed to all Users who had Automatic Updates ON..., tja...! :shock:
(But it was the very first time some iMacros Version had a Beta-Testing Phase before the Official Release... (I've been asking for several years...!), then I guess we should already be Happy..., next time [even] better then...! :wink: )

Worth reading the Beta-Testing Thread maybe..., is a bit long, 6 Pages I think, and I can sometimes be a bit "Verbose" (in my "Analytical Thinking"), and I think I acted a few times like a "perfect Drama Queen", oops-ah-ah...! :o , but was for "the Good Cause", ah-ah...!, I (already) knew I wouldn't be using that Version for myself..., but hum..., worth reading though I think... :idea: And maybe if a few other "Advanced" Users had participated during the Beta-Testing Phase, but I was the only-only-only one, maybe the "Final Result" could have been a bit different/better..., dunno...! :?
- (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...
groundfalling
Posts: 46
Joined: Tue Jul 01, 2014 1:26 pm

Re: Launch imacros from terminal using imacros://run/?m=

Post by groundfalling » Mon Sep 10, 2018 5:32 am

Been seeing you active on this forum for years so i always assumed that you were a part imacros.net team, didn't know that you were only a user yourself. The problem is that Firefox non-quantum versions are getting obsolete and many websites are putting restrictions to update the browser in order to access some of the features. so i have no choice but to use the latest Firefox version therefore stuck with this good for nothing imacros 10. but again i dont mind paying them for license as long as the new version is fully compatible with quantum Firefox and does not crash or disable or uninstall just with the browser launch.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Launch imacros from terminal using imacros://run/?m=

Post by chivracq » Mon Sep 10, 2018 6:27 am

groundfalling wrote:Been seeing you active on this forum for years so i always assumed that you were a part imacros.net team, didn't know that you were only a user yourself. The problem is that Firefox non-quantum versions are getting obsolete and many websites are putting restrictions to update the browser in order to access some of the features. so i have no choice but to use the latest Firefox version therefore stuck with this good for nothing imacros 10. but again i dont mind paying them for license as long as the new version is fully compatible with quantum Firefox and does not crash or disable or uninstall just with the browser launch.
Yeah well, "part of the imacros.net team"... (hum, like that, sounds nice, ah-ah...! :P ), but hum..., yeah, a mini-little bit indeed, became Mod 2 or 3 years ago, but my only "Purpose" is to prevent Spam on the Forum, you can check the Spam-Stats in this Post, ah-ah...!, but further than that, I'm still just a "normal" User, a bit "Creative"/"Advanced" ah-ah...! I don't even have a License for all the 'PE' Versions, and I've never used iMB even, ah-ah...!

(Like I already mentioned, I still use v8.8.2 for FF for myself..., oops...!)

I would think/hope, some v10.0.3 Version for FF will come some time..., hopefully with some shortened Beta-Testing Phase, not sure though, I guess they (Tech/Dev) found me a bit "annoying" ah-ah...! :shock:
=> Did you read the Beta-Testing Thread btw....? Any feedback...? (Can't post in the Thread itself, is locked now..., here is OK... 8) )
- (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...
groundfalling
Posts: 46
Joined: Tue Jul 01, 2014 1:26 pm

Re: Launch imacros from terminal using imacros://run/?m=

Post by groundfalling » Mon Sep 10, 2018 10:52 am

so i was able to find a workaround in case the pre-installed imacros 10 addon crash or disable or uninstall at the time of browser launch.
Download the imacros xpi

Code: Select all

imacros_for_firefox-10.0.2.1450-an+fx-linux.xpi
rename it to

Code: Select all

{81BF1D23-5F17-408D-AC6B-BD6DF7CAF670}.xpi
and copy it to the firefox profile "extensions" folder (which can be done by a one line code) and than when you launch the profile from terminal or script, the addon will surely be there and it will run the HTM file at the browser launch. BUT the only annoying thing is the PLAY dialog prompt which imacros 10.0.2.1450 shows and requires you to uncheck the "show this dialog next time" which again involves the manual click for the first time. Is there any way to disable this dialog box without modifying the addon files?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Launch imacros from terminal using imacros://run/?m=

Post by chivracq » Mon Sep 10, 2018 5:27 pm

groundfalling wrote:so i was able to find a workaround in case the pre-installed imacros 10 addon crash or disable or uninstall at the time of browser launch.
Download the imacros xpi

Code: Select all

imacros_for_firefox-10.0.2.1450-an+fx-linux.xpi
rename it to

Code: Select all

{81BF1D23-5F17-408D-AC6B-BD6DF7CAF670}.xpi
and copy it to the firefox profile "extensions" folder (which can be done by a one line code) and than when you launch the profile from terminal or script, the addon will surely be there and it will run the HTM file at the browser launch. BUT the only annoying thing is the PLAY dialog prompt which imacros 10.0.2.1450 shows and requires you to uncheck the "show this dialog next time" which again involves the manual click for the first time. Is there any way to disable this dialog box without modifying the addon files?
Hum, strange about the '.xpi' File disappearing I guess, and needing to be installed/copied again... :?

But the 'PLAY' Dialog is I guess the same you get like from the 'Click me to play' Link in my Quote in this Thread/Post (which doesn't work in v10.0.2, you then get the "Protocol" Error) and for which you had indeed, the first time you ran it, to "approve" the Execution... But I think that DialogBox was coming from the Browser itself, and not from iMacros, and some Security Exception would then be added/stored if I remember correctly to/in some Setting in 'about:config'..., this one I guess: 'extensions.imacros.white-list' (for v8.8.2, not sure at all it will exist as well for v10.0.2 in FF62, the "Mechanism" might now be different...)
- (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...
groundfalling
Posts: 46
Joined: Tue Jul 01, 2014 1:26 pm

Re: Launch imacros from terminal using imacros://run/?m=

Post by groundfalling » Tue Sep 11, 2018 8:47 am

found a workaround clicking the dialog box to uncheck and click 'play' using

Code: Select all

xdotool
next issue is finding a solution for 50 lines limit in the macro code. could you suggest anything?
Post Reply