How to run a macro from the command line using Chrome

Discussions and Tech Support related to the iMacros Google Chrome extension.
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.
chivracq
Posts: 7718
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to run a macro from the command line using Chrome

Post by chivracq » Mon Jan 15, 2018 7:46 pm

sanfric wrote:Hi
With Firefox, I use this procedure which works very well

Code: Select all

RetVal = Shell("C:\program files\Firefox\firefox.exe imacros://run/?m=TP.iim")
I followed Tom's procedure to do the same thing with Chrome

Code: Select all

RetVal = Shell("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe file:/// C:\Users\...\Documents\iMacros\Macros/TPS.htm")
Here is the TPS file. htm

Code: Select all

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

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

 
</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>

<
</script> 

 </html>
It works but there are two tabs opened: an useless "TPS.htm" tab with "Lauch Cr iMacros" an after the web page defined in the instructions of the script.

How to have only the web page without the TPS.htm tab ? Or close immédiately this tab?

thank you in advance for your help.
Sanfric
FCIM...! :mrgreen: (Read my Sig...)

Simply use a:

Code: Select all

TAB CLOSEALLOTHERS
in your '.iim' Script if you don't mind closing all "other" Tabs, or a:

Code: Select all

TAB T=0
TAB CLOSE
if you only want to close the "previous" Tab, I would think...
You might need '!ERRORIGNORE' for the Script to pass Parsing-Validation as I think there is a Check there for 'TAB T>0', but Negative Tab_Nbs do work, at least in iMacros for FF until at least v8.9.7, I reckon it will work in iMacros for CR as well, v8.4.4 or v10.0.

Hum, and mini-Detail, you have a "dangerous" or at least unneeded Space in "file:/// C:\Users\..."... :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...
sanfric
Posts: 35
Joined: Mon Dec 07, 2009 4:33 pm

Re: How to run a macro from the command line using Chrome

Post by sanfric » Thu Jan 18, 2018 12:39 pm

Hi,
Thank you for your help. The result is achieved. It's more clean!
Now, I'm looking for Chrome something equivalent to this code used with Firefox

Code: Select all

TAG POS=1 TYPE=TEXTAREA FORM=NAME:PAGE_ARTICLES_NOUVEAU_TEXTE ATTR=ID:A7 CONTENT={{!clipboard}}
That allows me to paste in the web page I opened the contents of the clipboard from a Winword file .. I read that this procedure did not work with Chrome.

What can I do , in Chrome, for the same result as the Firefox code.

Thank for your answer

sanfric
chivracq
Posts: 7718
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to run a macro from the command line using Chrome

Post by chivracq » Thu Jan 18, 2018 12:53 pm

sanfric wrote:Hi,
Thank you for your help. The result is achieved. It's more clean!
Now, I'm looking for Chrome something equivalent to this code used with Firefox

Code: Select all

TAG POS=1 TYPE=TEXTAREA FORM=NAME:PAGE_ARTICLES_NOUVEAU_TEXTE ATTR=ID:A7 CONTENT={{!clipboard}}
That allows me to paste in the web page I opened the contents of the clipboard from a Winword file .. I read that this procedure did not work with Chrome.

What can I do , in Chrome, for the same result as the Firefox code.

Thank for your answer

sanfric
Yep, I have another Workaround for '{{!CLIPBOARD}}' on CR..., hum... maybe 2, hum 4 now, ah-ah...!, well, depending on your FCI... :roll:
=> Grrr...!, but FCIM again, sorry... Is it so complicated to mention 3 Versions about your Config...?
- (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...
sanfric
Posts: 35
Joined: Mon Dec 07, 2009 4:33 pm

Re: How to run a macro from the command line using Chrome

Post by sanfric » Thu Jan 18, 2018 4:24 pm

For Chivracq

I do not understand exactly what you are asking to me. May be my configuration?

Version 1709 (16229.192) Windows 10 Pro French

Chrome: Version 63.0.3239.132 (Official Build) (64-bit)

iMacros for Chrome: BUILD VERSION = 1001 RECORDER = CR


Sanfric
chivracq
Posts: 7718
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to run a macro from the command line using Chrome

Post by chivracq » Thu Jan 18, 2018 8:43 pm

sanfric wrote:For Chivracq

I do not understand exactly what you are asking to me. May be my configuration?

Code: Select all

Version 1709 (16229.192) Windows 10 Pro French

Chrome: Version 63.0.3239.132 (Official Build) (64-bit)

iMacros for Chrome: BUILD VERSION = 1001 RECORDER = CR
Sanfric
Yep, the 'C' in "FCI" stands for "Configuration", like explained in my Sig that I asked you to read... And if you registered in 2009, you should have had the time by now to read the Forum Rules for Required Info to include in your Posts when you start a Thread or post for the first time in some existing Thread, I would think... :roll:

So OK..., you are on iMacros for CR v10.0.1 + CR63, that means you can use the 'EVENT' Mode for a 'Ctrl^v' (= Clipboard 'Paste'), which is the easiest Workaround for pasting the Content of your OS Clipboard on CR as '{{!CLIPBOARD}}' is surprisingly not supported on CR.

Other possible Workarounds I would have in mind would be to use your 'Winword' Doc as a DataSource for iMacros if you convert it to a '.CSV' or '.TXT' File, or even open it from a 2nd Tab in your Browser as '.TXT' or '.HTML' File... ('.CSV' Files are often a bit "problematic" to open this way, as the '.CSV' File Extension is often associated to Excel which will then go "fighting" with the Browser on who is going to handle that File, at least on FF last time I had done some Testing with it...), and I wouldn't be very surprised if you even could open "Word" Docs directly from your Browser..., I've never tried...
Depending on if you "only" use the Free-Free Add-on for CR, v10.0.1 is now limited in Functionality and File Access is not supported anymore in the Free Version, then the '!DATASOURCE' Solutions wouldn't work.

Another possibility would be to convert your Word Doc to a GoogleDoc Doc that you then as well can open and extract or edit directly from your Script in a 2nd Tab. GoogleDocs work actually best on CR, the Integration is "smoother" than with other Browsers supported by iMacros...
- (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...
sanfric
Posts: 35
Joined: Mon Dec 07, 2009 4:33 pm

Re: How to run a macro from the command line using Chrome

Post by sanfric » Wed Jan 24, 2018 1:23 pm

Hi,
I tried several syntax from the wiki iMacros.I am not a developer: I can not find the correct syntax for Event
I can paste only the letter "V" with this code

Code: Select all

EVENT TYPE=KEYPRESS SELECTOR="HTML" CHAR="v" MODIFIERS="ctrl"
I see that MODIFIERS work only with Firefox but not with Chrome

What can I do for pasting the clipboard with CTRL+V with Chrome

Tnahks for your hlep
Sanfric
chivracq
Posts: 7718
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to run a macro from the command line using Chrome

Post by chivracq » Wed Jan 24, 2018 3:52 pm

sanfric wrote:Hi,
I tried several syntax from the wiki iMacros.I am not a developer: I can not find the correct syntax for Event
I can paste only the letter "V" with this code

Code: Select all

EVENT TYPE=KEYPRESS SELECTOR="HTML" CHAR="v" MODIFIERS="ctrl"
I see that MODIFIERS work only with Firefox but not with Chrome

What can I do for pasting the clipboard with CTRL+V with Chrome

Tnahks for your hlep
Sanfric
Arrggghhh...!!, oh yep-yep, you're right...!, grrr..., I forgot about the 'MODIFIERS' Parameter not being supported on CR, as I only use FF myself...

OK-OK-OK..., then..., pfff..., you'll have to go back to one of the other Alternatives I mentioned then, ah-ah...!

But hum..., stg to "investigate" then..., is that the iMacros for FF Add-on is coded in pure JavaScript, meaning the whole 'EVENT' Mode/Functionality must be achievable in pure JavaScript, with and without the 'Modifiers' Functionality, maybe other Advanced User @iimfun will know how if he notices this Thread, and/or you might want to check on the SOF Forum how accessing the OS Clipboard and/or triggering a 'Ctrl^v' can be done in pure JS, then you can probably apply that Syntax in iMacros using the 'URL GOTO=javascript' Syntax...
- (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...
destatez
Posts: 8
Joined: Wed May 28, 2014 5:19 pm

Re: How to run a macro from the command line using Chrome

Post by destatez » Fri Nov 30, 2018 1:35 am

I'm sorry, but I'm lost in space. I'm a SW developer and have played around with HTML, but I could find none of the "solutions" given above that would do the trick. Some were dependent on earlier posts and it was really difficult (impossible) to come up with a solution that would work. I'm running 64-bit Windows 10. I have the Chrome imacros extension configured to look at files. I have created no bookmarks to iim related files. I've put an example iim file below. I have over 200 of these that merely change the URL. If I have to my batch script can copy a generated iim file into a pre-defined iim file in a pre-defined folder. The bat file examples of starting Chrome pointing to a disc file are straightforward. What I am not sure of, for starters, is what this file is that I'm asking chrome to open. It would seem that it's an HTML file, but there are so many variations above that I'm not sure where to go. Most seem to have some un-intelligible codes that were somehow obtained from Chrome. Can someone provide a workable HTML file example, identify where the imacros commands are that are somehow embedded in it, or where that HTML points to an actual iim file. If there are some "magic" numbers from Chrome, can you rehearse how to get those and where they go in the HTML?

I'd sure appreciate this with over 200 of these files/web pages to run against.

Dave

Code: Select all

VERSION BUILD=1005 RECORDER=CR
URL GOTO=https://live.door43.org/u/Steve_HamNC/th_2ch_text_ulb/596c04362f/
TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=ID:print-button
wait SECONDS=5
SET !TIMEOUT_MACRO 15 
TAB T=2
SAVEAS TYPE=HTM FOLDER=C:\\Users\\DES\\Documents\\MSData\\WA\\IT_Tasks\\Renderings_of_Repos\\USFM_Downloads FILE=th_2ch_text_ulb.htm
TAB T=1
TAB CLOSEALLOTHERS
Post Reply