It's possible to start iMacros (bookmark) with Loop?

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
Torsten156
Posts: 12
Joined: Wed Jul 08, 2020 6:18 am

It's possible to start iMacros (bookmark) with Loop?

Post by Torsten156 » Tue Jul 28, 2020 8:22 am

Hi,

i start my Script via CommandLine in a bat-File (see https://wiki.imacros.net/Webextensions Command Line Support). It works fine.
Now i would like to start the script with a Loop of 10 times. Is this possible with the bookmark-solution???

Here my Configuration:

Code: Select all

- iMacro for Chrome (Free Edition) 10.0.5
- Chrome Version 80.0.3987.122 (Offizieller Build) (64-Bit)
- WIN 10 Enterprise
reagrds
Torsten
Tom, Tech Support
Posts: 3601
Joined: Mon May 31, 2010 4:59 pm

Re: It's possible to start iMacros (bookmark) with Loop?

Post by Tom, Tech Support » Thu Jul 30, 2020 8:41 am

Hi Torsten156,

This might be possible, but I am not sure if it will work. I will have to see if I can get something working and get back to you.
Regards,

Tom, iMacros Support
Torsten156
Posts: 12
Joined: Wed Jul 08, 2020 6:18 am

Re: It's possible to start iMacros (bookmark) with Loop?

Post by Torsten156 » Thu Jul 30, 2020 11:58 am

Hi Tom,

great, thanks.

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

Re: It's possible to start iMacros (bookmark) with Loop?

Post by chivracq » Sun Aug 02, 2020 1:15 am

Torsten156 wrote:
Tue Jul 28, 2020 8:22 am
Hi,

i start my Script via CommandLine in a bat-File (see https://wiki.imacros.net/Webextensions Command Line Support). It works fine.
Now i would like to start the script with a Loop of 10 times. Is this possible with the bookmark-solution???

Here my Configuration:

Code: Select all

- iMacro for Chrome (Free Edition) 10.0.5
- Chrome Version 80.0.3987.122 (Offizieller Build) (64-Bit)
- WIN 10 Enterprise
reagrds
Torsten
Tom, Tech Support wrote:
Thu Jul 30, 2020 8:41 am
Hi Torsten156,

This might be possible, but I am not sure if it will work. I will have to see if I can get something working and get back to you.

"might be possible", ah-ah...!, yep it is, ... "I think"..., I have 3 or 4 (possible) Solutions... 8)
- (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...
Torsten156
Posts: 12
Joined: Wed Jul 08, 2020 6:18 am

Re: It's possible to start iMacros (bookmark) with Loop?

Post by Torsten156 » Mon Aug 03, 2020 9:48 am

realy? Give it to me!
chivracq
Posts: 9374
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: It's possible to start iMacros (bookmark) with Loop?

Post by chivracq » Mon Aug 03, 2020 5:41 pm

Torsten156 wrote:
Mon Aug 03, 2020 9:48 am
realy? Give it to me!

Yeah-yeah, be "patient", I want to "see" what @Tom from TechSup will come up with, ah-ah...!

Hum, and I can think of another 3 or 4 more (possible) Solutions, Total = 7 or 8 now, I've lost the Count..., nearly all of them based on some simple "Tricks" and on the same Principles..., Looping from '.bat'/'.ps' / Looping from iMacros / Looping from JS / Macro calling itself / (Auto-)Refresh/Reload the '.html'...
- (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...
Torsten156
Posts: 12
Joined: Wed Jul 08, 2020 6:18 am

Re: It's possible to start iMacros (bookmark) with Loop?

Post by Torsten156 » Wed Aug 05, 2020 11:42 am

I think I asked my question wrong. I don't mean calling the bookmark in a loop. I mean, how can I tell the call of the bookmark what value my LOOP should have in my script? And this via Commandline...
chivracq
Posts: 9374
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: It's possible to start iMacros (bookmark) with Loop?

Post by chivracq » Wed Aug 05, 2020 3:59 pm

Torsten156 wrote:
Wed Aug 05, 2020 11:42 am
I think I asked my question wrong. I don't mean calling the bookmark in a loop. I mean, how can I tell the call of the bookmark what value my LOOP should have in my script? And this via Commandline...

Yeah well, both your Thread Title and your OP were asking if it's possible to loop a Script lunched from a Bookmark/Bookmarklet, so I answer that Qt... You didn't post any Script so it's a bit difficult to know what you are doing exactly and how, so I can only answer generically with some endless if-if-if Reasoning...

=> Can you post your both Scripts...?, both the '.bat' File and your "Bookmark" Script...?
And if you already know how to do the Looping, how do you do it...?, which Method do you use...?

"I don't mean calling the bookmark in a loop."
=> Yeah well, why not...? A Loop is a Loop, and calling the Bookmark in a Loop is a Way for looping your iMacros Script... Then indeed, telling iMacros the "How Many Times" to loop the Script is the next Qt, ah-ah...!, either "How Many" to loop, or for some "Infinite Looping", after "How Many Loops", when to stop...

Then for passing a Var or a Value from your '.bat' File to the Script, there are different Solutions...:
1- No Need because already handled if you handle the Looping directly already from the '.bat'/'.cmd'/'.ps' Script in a similar/adapted Way like other Advanced User @'The iMacros Guru' had provided for example in this Thread...
He had gone for an Infinite Loop and breaking out with a Double 'goto', easy to modify the 'if' Condition for your Need, or there is probably some "for" Loop in 'cmd'...

2- Use the OS Clipboard to pass your Var, with for example 'clip.exe' from your '.bat' File, but there are many different Solutions like you can see for example here and here...
Then from the Macro, you can access the Clipboard using the '!CLIPBOARD' Var to set the Looping or to abort the Script after the "How Many Times" with some Conditional 'FAIL_IF_FOUND' or 'EVAL()' + 'MacroError()' or Toggling '!ERRORIGNORE', etc...
If the Looping is handled by JS from your Bookmark, I guess there is probably a Way to access the Clipboard in JS, or your iMacros Script could inject it in the HTML of the Page.

3- You could also pass that Var included in the FileName or the Path of your '.html' File/Bookmark, and iMacros can extract it through '!URLCURRENT' and 'EVAL()'.

4- You can also pass that Var/Value via some separate Online or Local Web-Page/Form or GoogleSheet for example.

... So like I said..., those are Generic if-if-if Solutions as you didn't post any Script... :|
- (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: 3601
Joined: Mon May 31, 2010 4:59 pm

Re: It's possible to start iMacros (bookmark) with Loop?

Post by Tom, Tech Support » Mon Aug 10, 2020 7:30 am

My apologies Torsten156, I have had no time lately to follow up with this, but chivracq has certainly provided a number of suggestions that could possibly work for you. He also makes a good point about posting your html, macro, and batch file code so that we know exactly which scenario we are attempting to solve. If I understood your original request correctly, I'm thinking the clipboard idea may be the easiest / most straightforward to implement.
Regards,

Tom, iMacros Support
Torsten156
Posts: 12
Joined: Wed Jul 08, 2020 6:18 am

Re: It's possible to start iMacros (bookmark) with Loop?

Post by Torsten156 » Tue Aug 11, 2020 5:55 pm

Hi Tom, thanks for your reply.

Hi chivrak,
here my code:

Macro:

Code: Select all

VERSION BUILD=1005 RECORDER=CR
SET !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
URL GOTO=https://xxx.xxx.com/
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:# ATTR=ID:username CONTENT=XXX
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:# ATTR=NAME:password CONTENT=XXX
TAG POS=1 TYPE=SPAN ATTR=ID:dijit_form_Button_4_label
WAIT SECONDS=7
TAG POS=1 TYPE=DIV ATTR=ID:dijit_layout_ContentPane_0
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_7_text
WAIT SECONDS=2

SET !VAR1 0

ADD !VAR1 {{!LOOP}}
TAG POS={{!VAR1}} TYPE=I ATTR=CLASS:fa<SP>fa-table<SP>optionsIcon
WAIT SECONDS=2
TAG POS=3 TYPE=SPAN ATTR=CLASS:dijitReset<SP>dijitInline<SP>dijitArrowButtonInner
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_16_text
TAG POS=1 TYPE=I ATTR=CLASS:action-icon<SP>fa<SP>fa-compress&&DATA-DOJO-ATTACH-POINT:iconNode
this is my Batchfile:

Code: Select all

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" file:///C:/web/start_edis_export.html
timeout 10

And here my Code in the web-page:

Code: Select all

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

    <script>
        var e_m64 = "VkVSU0lPTiUyMEJVSUxEJTNEMTAwNSUyMFJFQ09SREVSJTNEQ1IlMEFTRVQlMjAhVElNRU9VVF9TVEVQJTIwMSUwQVNFVCUyMCFFUlJPUklHTk9SRSUyMFlFUyUwQVVSTCUyMEdPVE8lM0RodHRwcyUzQSUyRiUyRmVkaXN3ZWIuZXZvbmlrLmNvbSUyRiUwQVRBRyUyMFBPUyUzRDElMjBUWVBFJTNESU5QVVQlM0FURVhUJTIwRk9STSUzREFDVElPTiUzQSUyMyUyMEFUVFIlM0RJRCUzQXVzZXJuYW1lJTIwQ09OVEVOVCUzRFY0OTA5JTBBU0VUJTIwIUVOQ1JZUFRJT04lMjBOTyUwQVRBRyUyMFBPUyUzRDElMjBUWVBFJTNESU5QVVQlM0FQQVNTV09SRCUyMEZPUk0lM0RBQ1RJT04lM0ElMjMlMjBBVFRSJTNETkFNRSUzQXBhc3N3b3JkJTIwQ09OVEVOVCUzRGpkaCUyM3ppdSUyNnRkei05dXolMEFUQUclMjBQT1MlM0QxJTIwVFlQRSUzRFNQQU4lMjBBVFRSJTNESUQlM0FkaWppdF9mb3JtX0J1dHRvbl80X2xhYmVsJTBBV0FJVCUyMFNFQ09ORFMlM0Q3JTBBVEFHJTIwUE9TJTNEMSUyMFRZUEUlM0RESVYlMjBBVFRSJTNESUQlM0FkaWppdF9sYXlvdXRfQ29udGVudFBhbmVfMCUwQVRBRyUyMFBPUyUzRDElMjBUWVBFJTNEVEQlMjBBVFRSJTNESUQlM0FkaWppdF9NZW51SXRlbV83X3RleHQlMEFXQUlUJTIwU0VDT05EUyUzRDIlMEElMEFTRVQlMjAhVkFSMSUyMDAlMEElMEFBREQlMjAhVkFSMSUyMCU3QiU3QiFMT09QJTdEJTdEJTBBVEFHJTIwUE9TJTNEJTdCJTdCIVZBUjElN0QlN0QlMjBUWVBFJTNESSUyMEFUVFIlM0RDTEFTUyUzQWZhJTNDU1AlM0VmYS10YWJsZSUzQ1NQJTNFb3B0aW9uc0ljb24lMEFXQUlUJTIwU0VDT05EUyUzRDIlMEFUQUclMjBQT1MlM0QzJTIwVFlQRSUzRFNQQU4lMjBBVFRSJTNEQ0xBU1MlM0FkaWppdFJlc2V0JTNDU1AlM0VkaWppdElubGluZSUzQ1NQJTNFZGlqaXRBcnJvd0J1dHRvbklubmVyJTBBVEFHJTIwUE9TJTNEMSUyMFRZUEUlM0RURCUyMEFUVFIlM0RJRCUzQWRpaml0X01lbnVJdGVtXzE2X3RleHQlMEFUQUclMjBQT1MlM0QxJTIwVFlQRSUzREklMjBBVFRSJTNEQ0xBU1MlM0FhY3Rpb24taWNvbiUzQ1NQJTNFZmElM0NTUCUzRWZhLWNvbXByZXNzJTI2JTI2REFUQS1ET0pPLUFUVEFDSC1QT0lOVCUzQWljb25Ob2RlJTBB";
    </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());}}) ();">Starte iMacros zum OEE-Download</a>

</body>
</html>
The iMacro works well. But, i start this directly in Chrome with a Loop-count from 5, or 6 or what ever.. Works well.

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

Re: It's possible to start iMacros (bookmark) with Loop?

Post by chivracq » Tue Aug 11, 2020 10:45 pm

Torsten156 wrote:
Tue Aug 11, 2020 5:55 pm
Hi Tom, thanks for your reply.

Hi chivrak,
here my code:

Macro:

Code: Select all

VERSION BUILD=1005 RECORDER=CR
SET !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
URL GOTO=https://xxx.xxx.com/
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:# ATTR=ID:username CONTENT=XXX
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:# ATTR=NAME:password CONTENT=XXX
TAG POS=1 TYPE=SPAN ATTR=ID:dijit_form_Button_4_label
WAIT SECONDS=7
TAG POS=1 TYPE=DIV ATTR=ID:dijit_layout_ContentPane_0
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_7_text
WAIT SECONDS=2

SET !VAR1 0

ADD !VAR1 {{!LOOP}}
TAG POS={{!VAR1}} TYPE=I ATTR=CLASS:fa<SP>fa-table<SP>optionsIcon
WAIT SECONDS=2
TAG POS=3 TYPE=SPAN ATTR=CLASS:dijitReset<SP>dijitInline<SP>dijitArrowButtonInner
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_16_text
TAG POS=1 TYPE=I ATTR=CLASS:action-icon<SP>fa<SP>fa-compress&&DATA-DOJO-ATTACH-POINT:iconNode
this is my Batchfile:

Code: Select all

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" file:///C:/web/start_edis_export.html
timeout 10

And here my Code in the web-page:

Code: Select all

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

    <script>
        var e_m64 = "VkVSU0lPTiUyMEJVSUxEJTNEMTAwNSUyMFJFQ09SREVSJTNEQ1IlMEFTRVQlMjAhVElNRU9VVF9TVEVQJTIwMSUwQVNFVCUyMCFFUlJPUklHTk9SRSUyMFlFUyUwQVVSTCUyMEdPVE8lM0RodHRwcyUzQSUyRiUyRmVkaXN3ZWIuZXZvbmlrLmNvb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ZUEUlM0RURCUyMEFUVFIlM0RJRCUzQWRpaml0X01lbnVJdGVtXzE2X3RleHQlMEFUQUclMjBQT1MlM0QxJTIwVFlQRSUzREklMjBBVFRSJTNEQ0xBU1MlM0FhY3Rpb24taWNvbiUzQ1NQJTNFZmElM0NTUCUzRWZhLWNvbXByZXNzJTI2JTI2REFUQS1ET0pPLUFUVEFDSC1QT0lOVCUzQWljb25Ob2RlJTBB";
    </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());}}) ();">Starte iMacros zum OEE-Download</a>

</body>
</html>
The iMacro works well. But, i start this directly in Chrome with a Loop-count from 5, or 6 or what ever.. Works well.

regards

Hum OK, good-good, but hum..., I don't "see" any Looping Mechanism in any of the 3 Scripts, apart from the fairly "Standard" "ADD !VAR1 {{!LOOP}}" in the '.iim' Macro, unless I'm "missing" the Meaning of one of the "true" Params in one of the JS 'xxxEvent()' Calls, and I didn't check redecompiling your 'e_m64' Var if it indeed contains the Macro you posted, so I'm still "a bit" unsure how you already handle your Looping, + no Use of the OS Clipboard or any of the 5 Methods I mentioned to pass a Var...

And hum, mini-Rmk, but I don't really see the (Purp[o/])Use either to keep the Login Part in the Looping, I reckon you only need to log in once... :o
No big-bid deal probably, but it's not very "efficient"..., unless you expect to get logged out regularly if you have a "very bad" Connection, hum OK...
- (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...
Post Reply