Start iMacro with command lines

Discussions and Tech Support related to the iMacros Google Chrome extension.

Moderators: Community Moderators, iMacros Moderators

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.

Start iMacro with command lines

by aorfevrebr on Mon Mar 12, 2018 8:36 pm

EDIT -------
Thank you for your fast reply.

Concerning my configuration, I'm using :
* Chrome Version 65.0.3325.146
* iMacros for Chrome 10.0.1
* macOs High Sierra v10.13.3

I've started a fresh html file using https://wiki.imacros.net/iMacros_for_Ch ... ne_Support
So my index.html is :
Code: Select all
 <html>
     <body onload="window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000);">

        <script>
           var e_m64 = "UFJPTVBUJTIwSEVMTE8hJTBBVVJMJTIwR09UTyUzRGh0dHAlM0ElMkYlMkZpbWFjcm9zLm5ldCUyRiUwQVBST01QVCUyMEJZRSE";
        </script>

        <a id="criimlaunch" href="javascript:(function() {try{if(!/^(?:chrome|https?|file)/.test(location)){alert('iMacros: Open webpage to run a macro.');return;}
           var macro = {};macro.source = decodeURIComponent(atob(e_m64));macro.name = 'MacroBookmarklet';
           var evt = document.createEvent('CustomEvent');evt.initCustomEvent('iMacrosRunMacro', true, true, macro);
           window.dispatchEvent(evt);}catch(e){alert('iMacros Bookmarklet error: '+e.toString());}}) ();">Launch CR iMacros</a>

     </body>
 </html>


And I plan to run it from command line with the following command :
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir "file:///Users/rizze/Desktop/RIZZE/fb-spammer/www/iMacros/index.html"

I see a new window opening but in command line I have the follwing error :
Macbook:~ rizze$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir "file:///Users/www/iMacros/index.html"
Nouvelle fenêtre ouverte dans la session du navigateur
[833:85763:0313/085533.690232:ERROR:browser_gpu_channel_host_factory.cc(120)] Failed to launch GPU process.



I have update my complete first question to keep only that.
My previous question was unclear
------------------ OLD QUESTION, NOT CLEAR, DO NOT PAY ATTENTION

Dear all,

First of all; I made multiples tests and research before asking this question. It s with total dispear that I ask you that.
If have seen this post :
* https://wiki.imacros.net/iMacros_for_Ch ... ne_Support
and many others.
I assume that the solution is somewhere here.

So here is my issue:
1/ When I laucnh the macro manually; everything is ok
2/ When I try to launch it from my HTML & Chrome it is not working.

here is my html :
Code: Select all
<html>
     <body onload="window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000);">
<!-- window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000); -->
<script src="https://code.jquery.com/jquery.js"></script>
<script src="iMacro_tools.js"></script>
        

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


Now here is my tools.js
Code: Select all
var launchMacro = function() {
    try {
        console.log("entering test", iMacros, _getFromQuery("name"))
        var e_m64;
        var n64;
        for (var i = 0; i < iMacros.length; i++) {
            console.log("iMacros.length", iMacros.length, iMacros[i].name, _getFromQuery("name"))
            if (iMacros[i].name === _getFromQuery("name")) {

                e_m64 = iMacros[i].e_m64;
                n64 = btoa(iMacros[i].name + ".iim");

                  console.log("e_m64", e_m64)
            }
        }
   
        if (!/^(?:chrome|https?|file)/.test(location)) {
            alert('iMacros: Open webpage to run a macro.');
            return;
        }
        var macro = {};

        //  console.log("Macro code", decodeURIComponent(atob(e_m64)))


        macro.source = decodeURIComponent(atob(e_m64));
        macro.name = decodeURIComponent(atob(n64));
        console.log("iMacro", macro)
        var evt = document.createEvent("CustomEvent");
        evt.initCustomEvent("iMacrosRunMacro", true, true, macro);
        window.dispatchEvent(evt);
    } catch (e) {
        alert('iMacros Bookmarklet error: ' + e.toString());

    }
}
var iMacros = [];
setTimeout(function() {


    $.getJSON("myBookMarks.json", function(json) {
        console.warn("big json loaded", json)
        iMacros = json;
//        launchMacro()

    });


}, 1000);


I do see my log correctly :
console.log("iMacro", macro)

for me; this is this part that is not starting properly :

Code: Select all
        var evt = document.createEvent("CustomEvent");
        evt.initCustomEvent("iMacrosRunMacro", true, true, macro);
        window.dispatchEvent(evt);

The event does not seems to be created / launched.
Nothing happened; I see my console.log and then nothing. The macro is not starting.

Moreover; I do start chrome with the following command line :
Code: Select all
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir "file:///MYDIR/iMacros/iMacro.html?name=iMacroAORF_FB.iim"


Do you guys have some suggestions for me please ?
I d be very gratefull for any help or advice.
Last edited by aorfevrebr on Tue Mar 13, 2018 5:03 am, edited 2 times in total.
aorfevrebr
 
Posts: 2
Joined: Mon Mar 12, 2018 8:17 pm

Re: Start iMacro with command lines

by chivracq on Mon Mar 12, 2018 10:27 pm

aorfevrebr wrote:Dear all,

First of all; I made multiples tests and research before asking this question. It s with total dispear that I ask you that.
If have seen this post :
* https://wiki.imacros.net/iMacros_for_Ch ... ne_Support
and many others.
I assume that the solution is somewhere here.

So here is my issue:
1/ When I laucnh the macro manually; everything is ok
2/ When I try to launch it from my HTML & Chrome it is not working.

here is my html :
Code: Select all
<html>
     <body onload="window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000);">
<!-- window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000); -->
<script src="https://code.jquery.com/jquery.js"></script>
<script src="iMacro_tools.js"></script>
        

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


Now here is my tools.js
Code: Select all
var launchMacro = function() {
    try {
        console.log("entering test", iMacros, _getFromQuery("name"))
        var e_m64;
        var n64;
        for (var i = 0; i < iMacros.length; i++) {
            console.log("iMacros.length", iMacros.length, iMacros[i].name, _getFromQuery("name"))
            if (iMacros[i].name === _getFromQuery("name")) {

                e_m64 = iMacros[i].e_m64;
                n64 = btoa(iMacros[i].name + ".iim");

                  console.log("e_m64", e_m64)
            }
        }
   
        if (!/^(?:chrome|https?|file)/.test(location)) {
            alert('iMacros: Open webpage to run a macro.');
            return;
        }
        var macro = {};

        //  console.log("Macro code", decodeURIComponent(atob(e_m64)))


        macro.source = decodeURIComponent(atob(e_m64));
        macro.name = decodeURIComponent(atob(n64));
        console.log("iMacro", macro)
        var evt = document.createEvent("CustomEvent");
        evt.initCustomEvent("iMacrosRunMacro", true, true, macro);
        window.dispatchEvent(evt);
    } catch (e) {
        alert('iMacros Bookmarklet error: ' + e.toString());

    }
}
var iMacros = [];
setTimeout(function() {


    $.getJSON("myBookMarks.json", function(json) {
        console.warn("big json loaded", json)
        iMacros = json;
//        launchMacro()

    });


}, 1000);


I do see my log correctly :
console.log("iMacro", macro)

for me; this is this part that is not starting properly :

Code: Select all
        var evt = document.createEvent("CustomEvent");
        evt.initCustomEvent("iMacrosRunMacro", true, true, macro);
        window.dispatchEvent(evt);

The event does not seems to be created / launched.
Nothing happened; I see my console.log and then nothing. The macro is not starting.

Moreover; I do start chrome with the following command line :
Code: Select all
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir "file:///MYDIR/iMacros/iMacro.html?name=iMacroAORF_FB.iim"


Do you guys have some suggestions for me please ?
I d be very gratefull for any help or advice.

Fouff-fouff-woaff-woaff...!! :shock: :twisted:

First of all: FCIM...! :mrgreen: (Read my Sig...!)
=> iMacros for CR v8.4.4/v10.0.1_Free...?, CR64/65...?, MacOS.
The only Info I could find about your Config, completely hidden in the middle of one of your Scripts is "MacOS"..., grrr...! :roll:

OK, my 2cts, as I don't use that Functionality at all myself, so I never "played" with it, and I don't use (iMacros for) CR anyway actually...!:
1- You are calling CR from the Command Line to start an '.iim' Macro. => Not good I would think, the Example from the Wiki that you referred to for this Technique requires to load a Local HTML Page which will launch a Macro embedded in the HTML Page as a Base-64 Encoded Macro or as an on-the-fly '.js' Script depending on for which Technique you choose, not an '.iim' Macro.

2- If using v10.0.1 for CR, and being on MacOS, there is no FIO-Module for File-Access on Linux + MacOS and you can (for the moment...?) only use Macros as Bookmarklets, and not as '.iim' Files.
(FIO = File I/O)

Ah no, OK, my bad about my first Remark '1-'...! :oops: , you are actually calling your "iMacro.html" Page/Local File from the Command Line, the '.iim' Macro Name is only passed in the URL as a Parameter... Okay... :wink:
Yeah, but back to the 'FIO' part then... iMacros for CR since around CR39 I think, is not able to read/save directly '.iim' Local Files without the Use of an "extra"/external FIO-Module for File Access, which is OS-dependent... If your Method worked, that would mean that you've found a way to bypass the Need for the FIO-Module...! 8)
- (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...
chivracq
 
Posts: 7562
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Start iMacro with command lines

by aorfevrebr on Tue Mar 13, 2018 4:57 am

chivracq wrote:
aorfevrebr wrote:Dear all,

First of all; I made multiples tests and research before asking this question. It s with total dispear that I ask you that.
If have seen this post :
* https://wiki.imacros.net/iMacros_for_Ch ... ne_Support
and many others.
I assume that the solution is somewhere here.

So here is my issue:
1/ When I laucnh the macro manually; everything is ok
2/ When I try to launch it from my HTML & Chrome it is not working.

here is my html :
Code: Select all
<html>
     <body onload="window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000);">
<!-- window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000); -->
<script src="https://code.jquery.com/jquery.js"></script>
<script src="iMacro_tools.js"></script>
        

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


Now here is my tools.js
Code: Select all
var launchMacro = function() {
    try {
        console.log("entering test", iMacros, _getFromQuery("name"))
        var e_m64;
        var n64;
        for (var i = 0; i < iMacros.length; i++) {
            console.log("iMacros.length", iMacros.length, iMacros[i].name, _getFromQuery("name"))
            if (iMacros[i].name === _getFromQuery("name")) {

                e_m64 = iMacros[i].e_m64;
                n64 = btoa(iMacros[i].name + ".iim");

                  console.log("e_m64", e_m64)
            }
        }
   
        if (!/^(?:chrome|https?|file)/.test(location)) {
            alert('iMacros: Open webpage to run a macro.');
            return;
        }
        var macro = {};

        //  console.log("Macro code", decodeURIComponent(atob(e_m64)))


        macro.source = decodeURIComponent(atob(e_m64));
        macro.name = decodeURIComponent(atob(n64));
        console.log("iMacro", macro)
        var evt = document.createEvent("CustomEvent");
        evt.initCustomEvent("iMacrosRunMacro", true, true, macro);
        window.dispatchEvent(evt);
    } catch (e) {
        alert('iMacros Bookmarklet error: ' + e.toString());

    }
}
var iMacros = [];
setTimeout(function() {


    $.getJSON("myBookMarks.json", function(json) {
        console.warn("big json loaded", json)
        iMacros = json;
//        launchMacro()

    });


}, 1000);


I do see my log correctly :
console.log("iMacro", macro)

for me; this is this part that is not starting properly :

Code: Select all
        var evt = document.createEvent("CustomEvent");
        evt.initCustomEvent("iMacrosRunMacro", true, true, macro);
        window.dispatchEvent(evt);

The event does not seems to be created / launched.
Nothing happened; I see my console.log and then nothing. The macro is not starting.

Moreover; I do start chrome with the following command line :
Code: Select all
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir "file:///MYDIR/iMacros/iMacro.html?name=iMacroAORF_FB.iim"


Do you guys have some suggestions for me please ?
I d be very gratefull for any help or advice.

Fouff-fouff-woaff-woaff...!! :shock: :twisted:

First of all: FCIM...! :mrgreen: (Read my Sig...!)
=> iMacros for CR v8.4.4/v10.0.1_Free...?, CR64/65...?, MacOS.
The only Info I could find about your Config, completely hidden in the middle of one of your Scripts is "MacOS"..., grrr...! :roll:

OK, my 2cts, as I don't use that Functionality at all myself, so I never "played" with it, and I don't use (iMacros for) CR anyway actually...!:
1- You are calling CR from the Command Line to start an '.iim' Macro. => Not good I would think, the Example from the Wiki that you referred to for this Technique requires to load a Local HTML Page which will launch a Macro embedded in the HTML Page as a Base-64 Encoded Macro or as an on-the-fly '.js' Script depending on for which Technique you choose, not an '.iim' Macro.

2- If using v10.0.1 for CR, and being on MacOS, there is no FIO-Module for File-Access on Linux + MacOS and you can (for the moment...?) only use Macros as Bookmarklets, and not as '.iim' Files.
(FIO = File I/O)

Ah no, OK, my bad about my first Remark '1-'...! :oops: , you are actually calling your "iMacro.html" Page/Local File from the Command Line, the '.iim' Macro Name is only passed in the URL as a Parameter... Okay... :wink:
Yeah, but back to the 'FIO' part then... iMacros for CR since around CR39 I think, is not able to read/save directly '.iim' Local Files without the Use of an "extra"/external FIO-Module for File Access, which is OS-dependent... If your Method worked, that would mean that you've found a way to bypass the Need for the FIO-Module...! 8)


Thank you for your fast reply.

Concerning my configuration, I'm using :
* Chrome Version 65.0.3325.146
* iMacros for Chrome 10.0.1
* macOs High Sierra v10.13.3

I've started a fresh html file using https://wiki.imacros.net/iMacros_for_Ch ... ne_Support
So my index.html is :
Code: Select all
 <html>
     <body onload="window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000);">

        <script>
           var e_m64 = "UFJPTVBUJTIwSEVMTE8hJTBBVVJMJTIwR09UTyUzRGh0dHAlM0ElMkYlMkZpbWFjcm9zLm5ldCUyRiUwQVBST01QVCUyMEJZRSE";
        </script>

        <a id="criimlaunch" href="javascript:(function() {try{if(!/^(?:chrome|https?|file)/.test(location)){alert('iMacros: Open webpage to run a macro.');return;}
           var macro = {};macro.source = decodeURIComponent(atob(e_m64));macro.name = 'MacroBookmarklet';
           var evt = document.createEvent('CustomEvent');evt.initCustomEvent('iMacrosRunMacro', true, true, macro);
           window.dispatchEvent(evt);}catch(e){alert('iMacros Bookmarklet error: '+e.toString());}}) ();">Launch CR iMacros</a>

     </body>
 </html>


And I plan to run it from command line with the following command :
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir "file:///Users/rizze/Desktop/RIZZE/fb-spammer/www/iMacros/index.html"

I see a new window opening but in command line I have the follwing error :
Macbook:~ rizze$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir "file:///Users/www/iMacros/index.html"
Nouvelle fenêtre ouverte dans la session du navigateur
[833:85763:0313/085533.690232:ERROR:browser_gpu_channel_host_factory.cc(120)] Failed to launch GPU process.



I have update my complete first question to keep only that.
My previous question was unclear
aorfevrebr
 
Posts: 2
Joined: Mon Mar 12, 2018 8:17 pm

Re: Start iMacro with command lines

by chivracq on Tue Mar 13, 2018 11:46 am

aorfevrebr wrote:Thank you for your fast reply.

Concerning my configuration, I'm using :
Code: Select all
* Chrome Version 65.0.3325.146
* iMacros for Chrome 10.0.1
* macOs High Sierra v10.13.3


I've started a fresh html file using https://wiki.imacros.net/iMacros_for_Ch ... ne_Support
So my index.html is :
Code: Select all
 <html>
     <body onload="window.setTimeout('document.getElementById(\'criimlaunch\').click();', 1000);">

        <script>
           var e_m64 = "UFJPTVBUJTIwSEVMTE8hJTBBVVJMJTIwR09UTyUzRGh0dHAlM0ElMkYlMkZpbWFjcm9zLm5ldCUyRiUwQVBST01QVCUyMEJZRSE";
        </script>

        <a id="criimlaunch" href="javascript:(function() {try{if(!/^(?:chrome|https?|file)/.test(location)){alert('iMacros: Open webpage to run a macro.');return;}
           var macro = {};macro.source = decodeURIComponent(atob(e_m64));macro.name = 'MacroBookmarklet';
           var evt = document.createEvent('CustomEvent');evt.initCustomEvent('iMacrosRunMacro', true, true, macro);
           window.dispatchEvent(evt);}catch(e){alert('iMacros Bookmarklet error: '+e.toString());}}) ();">Launch CR iMacros</a>

     </body>
 </html>


And I plan to run it from command line with the following command :
Code: Select all
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir "file:///Users/rizze/Desktop/RIZZE/fb-spammer/www/iMacros/index.html"


I see a new window opening but in command line I have the follwing error :
Macbook:~ rizze$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --disable-web-security --user-data-dir "file:///Users/www/iMacros/index.html"
Nouvelle fenêtre ouverte dans la session du navigateur
[833:85763:0313/085533.690232:ERROR:browser_gpu_channel_host_factory.cc(120)] Failed to launch GPU process.


I have update my complete first question to keep only that.
My previous question was unclear

OK for your FCI...
Hum, iMacros for CR v10.0.1 + CR65...
=> Oh...!, it would be "interesting" if you could post in this Thread where several Users have reported that after updating CR64 to CR65, they can no longer save a Macro (as Bookmark) they just recorded... The Content of that Thread is still a bit "unclear" as until now only one User (out of 3) posted "a bit correctly" with their FCI and some "good" Description, to mention if you encounter the same Pb or not... :idea:

Hum, you don't need to quote yourself again when posting, that makes the Thread less easy to follow... :roll:

But OK, the Runtime Error you mention seems to be related to some recurring Pb in different Versions for Chrome and Chromium, related to WebGL and Graphic Hardware Acceleration getting disabled, and that you might need to manually (re)enable in your 'Advanced Settings' in CR.
=> It's not clear to me if it is really iMacros that is triggering it... :?

Some "Test" you could run would be to (try to) launch some very "simple" HTML Page that doesn't try to call/launch any iMacros Macro, using the same Syntax you were using from the Command Line. Hum and maybe some other HTML Page with a few Images and then with some embedded Video to see if you get the same 'GPU' Runtime Error.
I don't use iMacros for CR myself, so I never dug into the guts of the CR Add-on and I don't know if iMacros for CR uses by any chance WebGL... I never checked that on FF either, ah-ah...! :oops:

Hum, and one more Test, there is a chance that if WebGL is used "somewhere" in the whole "Process" (by iMacros), that it's for the Base_64 Decoding part, then you could try with another HTML Page where your Macro is embedded as an on-the-fly '.js' Macro like explained in the 2nd Method in the Wiki... :idea:

>>>

And for those interested, parallel Thread on SOF:
- Launch iMacros for Chrome from command lines
=> ... where for the moment, User @Nic Endo as usual is trying to convert Users from iMacros to Kantu, tja...! 8)

Kantu is a Standalone Browser, then yep..., if the Pb is related to CR and WebGL, then I guess Kantu won't encounter it of course...! Hum..., not that sure about the "of course" actually, as Kantu is a Graphical Browser for Web-Automation, so I guess it could be using WebGL as well...
But then you (@OP) could use/try FF and iMacros for FF which is much more powerful than iMacros for CR anyway... :idea:
(Recommended Versions/FCI for FF: FF v55.0.3 + iMacros for FF v8.9.7.)
- (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...
chivracq
 
Posts: 7562
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Start iMacro with command lines

by chivracq on Thu Mar 15, 2018 12:18 pm

Hum..., no Follow-up anymore in this Thread :roll: , but I see that @OP posted in their parallel Thread on SOF:
I managed to do what I wanted with Kantu. [...] – aorfevre 17 hours ago

Hum, Okay..., that's a bit of a "Coward's Solution" ah-ah...! on one side, and very drastic on the other side, is my "Feeling" then... :?

If @OP could switch from CR to Kantu, which means they didn't have to stick to CR, then I would think they could better have switched to FF (FF v55.0.3 + iMacros for FF v8.9.7 or v9.0.3), which works pretty straightforward from the Command Line and Batch Files and is much more "powerful" than iMacros for CR, and they could keep using the same iMacros Script(s) directly, while by switching to Kantu, they necessarily had to completely rewrite their Script(s)..., unless Kantu offers some Import/Convert Functionality from iMacros to Kantu, but that's not the case afaik... :?
- (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...
chivracq
 
Posts: 7562
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Chrome

Who is online

Users browsing this forum: Google [Bot] and 3 guests

-->