How to run macros in Firefox/Chrome from the command line

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
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
destatez
Posts: 9
Joined: Wed May 28, 2014 5:19 pm

How to run macros in Firefox/Chrome from the command line

Post by destatez » Sat Dec 08, 2018 10:24 pm

I'm running Windows 10 on a 64 bit machine. I'm running Firefox: 63.0.3 (64-bit) with iMacros for Firefox 10.0.2.1450.

I'm trying to run an iMacros file from the command line. That command is given below. When I run it I get a pop-up error message that the file does not have an associated app. Attached is that error message, in full, a screen-shot of the Firefox Applications settings, showing iMacros, and finally a screen-shot of the iMacros add-on settings. I did install the iMacros file handling program. Where have I messed up? What do I need to do differently?

bat file script:

Code: Select all

start /wait /b "Run Firefox iMacro" "C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"  imacros://run/?m=DJIA.iim
DJIA.iim content

Code: Select all

VERSION BUILD=10021450
URL GOTO=https://www.marketwatch.com/investing/index/djia
SAVEAS TYPE=HTM FOLDER=C:\Users\DES\Documents\DJIA FILE={{!NOW:ddmmyyyy}}
Attachments
iMacros Settings in Firefox.jpg
The iMacros add-on settings for Firefox
Firefox imacros Applications setup.jpg
Association of imacros file type with imacros app
Firefox Default Apps Setting Error Msg.jpg
Firefox error message about undefined app association
Last edited by Tom, Tech Support on Mon Jan 14, 2019 9:59 pm, edited 1 time in total.
chivracq
Posts: 8696
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Firefox Default Apps Settings not working

Post by chivracq » Sun Dec 09, 2018 3:36 am

destatez wrote:I'm running

Code: Select all

Windows 10 on a 64 bit machine. I'm running Firefox: 63.0.3 (64-bit) with iMacros for Firefox 10.0.2.1450. 
I'm trying to run an iMacros file from the command line. That command is given below. When I run it I get a pop-up error message that the file does not have an associated app. Attached is that error message, in full, a screen-shot of the Firefox Applications settings, showing iMacros, and finally a screen-shot of the iMacros add-on settings. I did install the iMacros file handling program. Where have I messed up? What do I need to do differently?

bat file script:

Code: Select all

start /wait /b "Run Firefox iMacro" "C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"  imacros://run/?m=DJIA.iim
DJIA.iim content

Code: Select all

VERSION BUILD=10021450
URL GOTO=https://www.marketwatch.com/investing/index/djia
SAVEAS TYPE=HTM FOLDER=C:\Users\DES\Documents\DJIA FILE={{!NOW:ddmmyyyy}}
"Where have I messed up?"
=> Nowhere... :D , hum except from not following the Beta-Testing Phase + not reading the Release Notes + not following up (anymore) on your previous Threads..., if you had done so, you would have gotten an Answer to your previous Thread when you had posted it and you would already know the Answer to this current one.... :idea:

'Free'/'PE' is missing btw for your FCI... (... but won't make a Difference anyway, the Command Line 'imacros://run/?m=' Syntax is not supported anymore in v10.0.2 for FF...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
destatez
Posts: 9
Joined: Wed May 28, 2014 5:19 pm

Re: Firefox Default Apps Settings not working

Post by destatez » Mon Dec 10, 2018 12:40 am

Yes, I did miss the piece about my iMacros download. It was for the PE edition.

You talk about the Beta Testing Phase. There is no specific response for a search on "Beta Testing" from the iMacros wiki site. I did do what I thought was Beta testing by getting the iim file to run from the Sidebar.

On the release Notes topic, I have spent over 2 hours digging through web pages that don't seem to address the specifics of what I want to do. There's a lot about what I can't do, but that isn't too helpful. I went off on a little tangent about using python, but I can't seem to get the win32com lib to install, even after installing the Python Extentions for Windows for Python 2. There was also some discussion about just running iMacros.exe, but when I run the program nothing happens, no messages, no windows. I probably need the Business or enterprise editions to run that program.

For Firefox, here is part of handlers.json:
"imacros":{"action":4,"handlers":[{"name":"iMacros.Sidebar.exe","path":"C:\\Program Files (x86)\\Ipswitch\\iMacros\\iMacros.Sidebar.exe"},{"name":"iimrunner.exe","path":"C:\\Program Files (x86)\\Ipswitch\\iMacros\\iimrunner.exe"}]}}}

I must be missing something with the navigation under this forum. When I go to my post "Re: How to run a macro from the command line using Chrome by destatez on Thu Nov 29, 2018 8:35 pm" or my post "Re: Help with Batch File by destatez on Mon Nov 19, 2018 11:38 am" I find no replies to them. Yes, there were previous posts on these topics, but my posts were asking for a clarification of those previous ones. I'm confused where to look for the "not following up (anymore) on your previous Threads"
chivracq
Posts: 8696
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Firefox Default Apps Settings not working

Post by chivracq » Mon Dec 10, 2018 10:42 am

destatez wrote:Yes, I did miss the piece about my iMacros download. It was for the PE edition.
OK...
destatez wrote:You talk about the Beta Testing Phase. There is no specific response for a search on "Beta Testing" from the iMacros wiki site. I did do what I thought was Beta testing by getting the iim file to run from the Sidebar.

On the release Notes topic, I have spent over 2 hours digging through web pages that don't seem to address the specifics of what I want to do. There's a lot about what I can't do, but that isn't too helpful.
- Releases Notes for v10.0.2 for FF:
- Version 10.0.2, released July 9, 2018

- Beta-Testing for v10.0.2 for FF is the following (pinned) Thread in the 'iMacros for FF' Sub-Forum:
- iMacros 10 Beta - Sign Up and Provide Feedback Here!
A bit lenghty to read with its 6 Pages I guess, a bit my "fault" actually, oops...!, to read a bit like a "Diary" but will give you a more extended "Picture" of all Limitations (and Bugs left) for the v10.0.2 for FF Version that was finally released... and which is the Version you are using...
destatez wrote:I went off on a little tangent about using python, but I can't seem to get the win32com lib to install, even after installing the Python Extentions for Windows for Python 2. There was also some discussion about just running iMacros.exe, but when I run the program nothing happens, no messages, no windows. I probably need the Business or enterprise editions to run that program.

For Firefox, here is part of handlers.json:
"imacros":{"action":4,"handlers":[{"name":"iMacros.Sidebar.exe","path":"C:\\Program Files (x86)\\Ipswitch\\iMacros\\iMacros.Sidebar.exe"},{"name":"iimrunner.exe","path":"C:\\Program Files (x86)\\Ipswitch\\iMacros\\iimrunner.exe"}]}}}
Hum, dunno anything about Python, but if combined with 'iMacros.exe' / 'iMacros.Sidebar.exe' / iimrunner.exe', this is indeed using iMB and the 'Scripting Interface', only included in the 'iMacros Enterprise Edition'.
destatez wrote:I must be missing something with the navigation under this forum. When I go to my post "Re: How to run a macro from the command line using Chrome by destatez on Thu Nov 29, 2018 8:35 pm" or my post "Re: Help with Batch File by destatez on Mon Nov 19, 2018 11:38 am" I find no replies to them. Yes, there were previous posts on these topics, but my posts were asking for a clarification of those previous ones. I'm confused where to look for the "not following up (anymore) on your previous Threads"
Yeah well, I meant this Thread (with 2 final Posts from me and no Follow-up anymore) as you then posted 2 weeks later in some next Thread (here) a Script showing how you had actually (neatly) implemented the Tab Navigation I had mentioned in the "incriminated" Thread while you "could", hum or "should" (as I stopped answering your Threads after that) have posted this Script already to finish that Thread "a bit correctly"... :roll:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Tom, Tech Support
Posts: 3522
Joined: Mon May 31, 2010 4:59 pm

Re: Firefox Default Apps Settings not working

Post by Tom, Tech Support » Mon Dec 10, 2018 10:46 am

Hi destatez,

Have you already tried the method outlined here:

https://wiki.imacros.net/Webextensions# ... ne_Support

To be honest, running iMacros for Chrome or Firefox from the command line or a batch file is not a trivial endeavor when using just the freeware or Personal Edition. If this is something you wish to do reliably and consistently, you should consider upgrading to the Enterprise Edition, which provides an API for being able to launch and play macros in any supported browser quite easily.
Regards,

Tom, iMacros Support
destatez
Posts: 9
Joined: Wed May 28, 2014 5:19 pm

Re: Firefox Default Apps Settings not working

Post by destatez » Mon Dec 10, 2018 9:04 pm

Thanks for the link to the webextensions https://wiki.imacros.net/Webextensions# ... ne_Support. I implemented the "embedded" macros option as shown below. It works correctly for Firefox, but for Chrome I only get a web page with the text "Launch iMacros" and nothing else happens. Below the html code is the bat file, with the call to Firefox commented out.

Dave

Code: Select all

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

      <script>
         var macroCode = '';
         macroCode += 'VERSION BUILD=10021450\n';
         macroCode += 'URL GOTO=https://www.marketwatch.com/investing/index/djia\n';
         macroCode += 'SAVEAS TYPE=HTM FOLDER=C:\\Users\\DES\\Documents\\DJIA FILE={{!NOW:ddmmyyyy}}\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>

Code: Select all

@echo off
rem 
rem  DJIA_test.bat
rem   P
rem   P
rem   P
rem   P
rem 
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "file:///C:/Users/DES/Documents/DJIA.htm"
rem "C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"  "file:///C:/Users/DES/Documents/DJIA.htm"
exit /b
Tom, Tech Support
Posts: 3522
Joined: Mon May 31, 2010 4:59 pm

Re: Firefox Default Apps Settings not working

Post by Tom, Tech Support » Mon Jan 14, 2019 9:00 pm

chivracq wrote:
Sat Jan 12, 2019 5:01 am
I implemented the "embedded" macros option as shown below. It works correctly for Firefox, but for Chrome I only get a web page with the text "Launch iMacros" and nothing else happens.
I'm sorry to hear that it is no longer working for Chrome. Ipswitch doesn't officially support any method for running the freeware or Personal Edition versions of iMacros for Firefox or Chrome via the command line (lest we risk cannibalizing sales of Enterprise Edition, which are what help fund development of the freeware versions in the first place!). However, we don't shy away from promoting solutions from the user community, which is where this method originated. So if someone has a fix or a different solution, we will gladly add it to our wiki page.
Regards,

Tom, iMacros Support
destatez
Posts: 9
Joined: Wed May 28, 2014 5:19 pm

Re: Firefox Default Apps Settings not working

Post by destatez » Mon Jan 14, 2019 9:42 pm

Tom

Thanks for the input. I quess I'll just have to wait until another user posts a different solution.

Dave
Post Reply