Is it possible to loop a macro different days?

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 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
MrR
Posts: 4
Joined: Mon Apr 01, 2019 7:23 am

Is it possible to loop a macro different days?

Post by MrR » Mon Apr 01, 2019 7:38 am

Hi everyone,

I expose the easy part of the macro i want to create:
1. I need a macro that refresh a webpage and then submit a login form (already got it).
2. Once the webpage is refreshed click a span ( sadly that action is not recorded for IMacros... the span have an ID and a jsFunction onClick, if i can trigger it this will be ok as well )

The hard part:
1. The easy part needs to be in somekind of a loop, this action needs to be triggered everyday in a exact hour/datetime.
Extra. Some kind of random like from 0 to 10, to put it in the minutes of the hour/datetime.

What i have right now:
VERSION BUILD=1005 RECORDER=CR
URL GOTO=http://website/
FRAME F=1
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:intro ATTR=ID:user CONTENT=USERNAME
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:intro ATTR=ID:clau CONTENT=PASSWORD
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:intro ATTR=*

Thanks for reading :)
Hope you can help me.
chivracq
Posts: 8791
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Is it possible to loop a macro different days?

Post by chivracq » Mon Apr 01, 2019 2:58 pm

MrR wrote:
Mon Apr 01, 2019 7:38 am
Hi everyone,

I expose the easy part of the macro i want to create:
1. I need a macro that refresh a webpage and then submit a login form (already got it).
2. Once the webpage is refreshed click a span ( sadly that action is not recorded for IMacros... the span have an ID and a jsFunction onClick, if i can trigger it this will be ok as well )

The hard part:
1. The easy part needs to be in somekind of a loop, this action needs to be triggered everyday in a exact hour/datetime.
Extra. Some kind of random like from 0 to 10, to put it in the minutes of the hour/datetime.

What i have right now:

Code: Select all

VERSION BUILD=1005 RECORDER=CR
URL GOTO=http://website/
FRAME F=1
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:intro ATTR=ID:user CONTENT=USERNAME
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:intro ATTR=ID:clau CONTENT=PASSWORD
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:intro ATTR=*
Thanks for reading :)
Hope you can help me.
FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for CR v10.0.5, 'Free'/'PE'...?, CR73...?, OS...?

Your Thread has supposedly nothing specific to the 'iMacros for CR' Sub-Forum, especially if you don't mention your FCI... :roll: , try to select the/a "correct" Sub-Forum when you open a Thread... (=> Would have been the 'General' Sub-Forum for this current Thread... No need to duplicate now...)

1- About the 'SPAN' Element generated from some JS Script, not visible from your Script, no URL posted, then I can't have a look, but I would say try using the 'EVENT' Mode to see if that Mode is able to record that Action...

2- About the "... triggered everyday in a exact hour/datetime." + :
This is(/was) "usually/normally" achieved using the 'Command Line Syntax' (imacros://run/?m=) and launching your Macro from a '.BAT' File from your OS Task Scheduler, + if you are on Win_x32/_x64 as OS, the Delayed Random Minutes is also standard Functionality from the Win Task Scheduler, at least on Win10_x64 that I use now, but I think it was also already the case on Win7_x64.

BUT...!, and there is a big "BUT"...!, that 'Command Line Syntax' is "now" (currently) not supported anymore in iMacros for CR and FF v10.0.x. There is some kind of a "cumbersome" Workaround where the Macro already needs to be embedded into some local HTML Page..., but that will still work with the scheduled part from the OS Task Scheduler.

Another "BUT" is that you mention that your Script will also need to loop. That 'Looping' Functionality has always been "incompatible" with the 'Command Line Interface' (CLI) and Scripts launched from a '.BAT' File, even if there is some Workaround (hum, 2 actually..., oh...! 3 actually, ah-ah...!, and the 3rd one might work for you...!), the 1st Workaround is a Trick that relies on a Bug and that I don't want to "advertize" too much but that can be found if you search the Forum a bit, but I'm not sure if it (still) works in your v10.0.5 for CR Version, and I'm actually not even sure if it has ever worked on CR, as I don't use this Browser myself...

One Workaround that would work (for the Looping part), would be if you can launch your Macro "manually" everyday (in Loop Mode) from the iMacros Side Panel, where for '!LOOP'=1, you would have included a Conditional 'WAIT' until your specific Time of the Day that you want your Macro to "really" start to work. (Several Threads about "conditional+wait" if you search the Forum...)
Same Method can also be used for your extra few Random Minutes.

About the 2 (other) Workarounds I mentioned in my "Another BUT..." previous Paragraph, it's possible to have a Macro call itself (indefinitely) using the same 'imacros://run/?m=' Syntax from the CLI, this time from the 'URL GOTO' Command, even if that Syntax was never "officially" supported in any Version, but it works/worked... 8) BUT it doesn't work anymore in v10.0.x for CR+FF, ah-ah...! :P

But what would work I think :D (and that's the 3rd Workaround), would be that your embedded Macro launched from some local HTML Page could very well simply call and reload this very same local HTML Page at the end of the Macro, and I would then expect your Macro to go looping indefinitely, and that could also be "interesting" for Users using the 'Free' Version, as Looping is limited to 100 Loops in that Version. 8)

OK..., I hope you "understand" the many Options I mentioned, none is very straightforward, the easiest one I would think is the manual Launch of your Macro in Loop Mode with a Conditional ''WAIT' for the 1st Loop. Good luck and post your Final Implementation/Script once you've got it to work... :wink:
- (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...
MrR
Posts: 4
Joined: Mon Apr 01, 2019 7:23 am

Re: Is it possible to loop a macro different days?

Post by MrR » Thu Apr 04, 2019 9:32 am

chivracq wrote:
Mon Apr 01, 2019 2:58 pm
FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for CR v10.0.5, 'Free'/'PE'...?, CR73...?, OS...?

Your Thread has supposedly nothing specific to the 'iMacros for CR' Sub-Forum, especially if you don't mention your FCI... :roll: , try to select the/a "correct" Sub-Forum when you open a Thread... (=> Would have been the 'General' Sub-Forum for this current Thread... No need to duplicate now...)

1- About the 'SPAN' Element generated from some JS Script, not visible from your Script, no URL posted, then I can't have a look, but I would say try using the 'EVENT' Mode to see if that Mode is able to record that Action...

2- About the "... triggered everyday in a exact hour/datetime." + :
This is(/was) "usually/normally" achieved using the 'Command Line Syntax' (imacros://run/?m=) and launching your Macro from a '.BAT' File from your OS Task Scheduler, + if you are on Win_x32/_x64 as OS, the Delayed Random Minutes is also standard Functionality from the Win Task Scheduler, at least on Win10_x64 that I use now, but I think it was also already the case on Win7_x64.

BUT...!, and there is a big "BUT"...!, that 'Command Line Syntax' is "now" (currently) not supported anymore in iMacros for CR and FF v10.0.x. There is some kind of a "cumbersome" Workaround where the Macro already needs to be embedded into some local HTML Page..., but that will still work with the scheduled part from the OS Task Scheduler.

Another "BUT" is that you mention that your Script will also need to loop. That 'Looping' Functionality has always been "incompatible" with the 'Command Line Interface' (CLI) and Scripts launched from a '.BAT' File, even if there is some Workaround (hum, 2 actually..., oh...! 3 actually, ah-ah...!, and the 3rd one might work for you...!), the 1st Workaround is a Trick that relies on a Bug and that I don't want to "advertize" too much but that can be found if you search the Forum a bit, but I'm not sure if it (still) works in your v10.0.5 for CR Version, and I'm actually not even sure if it has ever worked on CR, as I don't use this Browser myself...

One Workaround that would work (for the Looping part), would be if you can launch your Macro "manually" everyday (in Loop Mode) from the iMacros Side Panel, where for '!LOOP'=1, you would have included a Conditional 'WAIT' until your specific Time of the Day that you want your Macro to "really" start to work. (Several Threads about "conditional+wait" if you search the Forum...)
Same Method can also be used for your extra few Random Minutes.

About the 2 (other) Workarounds I mentioned in my "Another BUT..." previous Paragraph, it's possible to have a Macro call itself (indefinitely) using the same 'imacros://run/?m=' Syntax from the CLI, this time from the 'URL GOTO' Command, even if that Syntax was never "officially" supported in any Version, but it works/worked... 8) BUT it doesn't work anymore in v10.0.x for CR+FF, ah-ah...! :P

But what would work I think :D (and that's the 3rd Workaround), would be that your embedded Macro launched from some local HTML Page could very well simply call and reload this very same local HTML Page at the end of the Macro, and I would then expect your Macro to go looping indefinitely, and that could also be "interesting" for Users using the 'Free' Version, as Looping is limited to 100 Loops in that Version. 8)

OK..., I hope you "understand" the many Options I mentioned, none is very straightforward, the easiest one I would think is the manual Launch of your Macro in Loop Mode with a Conditional ''WAIT' for the 1st Loop. Good luck and post your Final Implementation/Script once you've got it to work... :wink:
Wow! Thanks a lot for taking your time on reading and answering (super answer) my post beside what you have in your signature... let me repair the mess i done:
=> iMacros for CR v10.0.5, 'Free', 73.0.3683.86 64b, Win 10 Pro

About my target webpage is somekind of internal webpage to control the presence of the worker... as you can imagine i can't post many details :lol: and saddly you can't access to it.

About the span: The event mode seems to have done the job, THANSK!
The code:

Code: Select all

EVENT TYPE=KEYPRESS SELECTOR="HTML>BODY" KEY=46 MODIFIERS="ctrl|alt"
EVENT TYPE=KEYUP SELECTOR="HTML>BODY" KEY=18
EVENT TYPE=MOUSEDOWN SELECTOR="#logout" BUTTON=0
EVENT TYPE=MOUSEMOVE SELECTOR="#logout" POINT="(1038,180)"
EVENT TYPE=MOUSEUP POINT="(1038,180)"
EVENT TYPE=CLICK SELECTOR="#logout" BUTTON=0
I think i only need the CLICK part :mrgreen:

About the workaround: I think i'll adopt the 3rd workaround it seems the most "easy" for me.
I'll search info to make somekind of local HTML that does the next steps:
- Loop X times between diferent days
- And launch the iMacros extension in a certain date + random minutes :)

Is it possible to call a specific IMacros function via JavaScript? https://wiki.imacros.net/JavaScript only works for IE... is there any way to do it with chrome?

My script as iMacros right now:

Code: Select all

VERSION BUILD=1005 RECORDER=CR
URL GOTO=http://website/
FRAME F=1
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:intro ATTR=ID:user CONTENT=USERNAME
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:intro ATTR=ID:clau CONTENT=PASSWORD
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:intro ATTR=*
EVENT TYPE=CLICK SELECTOR="#logout" BUTTON=0
I'll post the JS once i have it and we will see if it worked :)

EDIT: i attempted to run it but when reaches the line: EVENT TYPE=CLICK SELECTOR="#logout" BUTTON=0 it prints the following error: the TypeError: Cannot read property 'error' of undefined, line: 8
MrR
Posts: 4
Joined: Mon Apr 01, 2019 7:23 am

Re: Is it possible to loop a macro different days?

Post by MrR » Fri Apr 05, 2019 10:09 am

UP
MrR
Posts: 4
Joined: Mon Apr 01, 2019 7:23 am

Re: Is it possible to loop a macro different days?

Post by MrR » Mon Apr 08, 2019 9:42 am

UP?
chivracq
Posts: 8791
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Is it possible to loop a macro different days?

Post by chivracq » Mon Apr 08, 2019 6:39 pm

MrR wrote:
Thu Apr 04, 2019 9:32 am
Wow! Thanks a lot for taking your time on reading and answering (super answer) my post beside what you have in your signature... let me repair the mess i done:
=> iMacros for CR v10.0.5, 'Free', 73.0.3683.86 64b, Win 10 Pro

About my target webpage is somekind of internal webpage to control the presence of the worker... as you can imagine i can't post many details :lol: and saddly you can't access to it.

About the span: The event mode seems to have done the job, THANSK!
The code:

Code: Select all

EVENT TYPE=KEYPRESS SELECTOR="HTML>BODY" KEY=46 MODIFIERS="ctrl|alt"
EVENT TYPE=KEYUP SELECTOR="HTML>BODY" KEY=18
EVENT TYPE=MOUSEDOWN SELECTOR="#logout" BUTTON=0
EVENT TYPE=MOUSEMOVE SELECTOR="#logout" POINT="(1038,180)"
EVENT TYPE=MOUSEUP POINT="(1038,180)"
EVENT TYPE=CLICK SELECTOR="#logout" BUTTON=0
I think i only need the CLICK part :mrgreen:

About the workaround: I think i'll adopt the 3rd workaround it seems the most "easy" for me.
I'll search info to make somekind of local HTML that does the next steps:
- Loop X times between diferent days
- And launch the iMacros extension in a certain date + random minutes :)

Is it possible to call a specific IMacros function via JavaScript? https://wiki.imacros.net/JavaScript only works for IE... is there any way to do it with chrome?

My script as iMacros right now:

Code: Select all

VERSION BUILD=1005 RECORDER=CR
URL GOTO=http://website/
FRAME F=1
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:intro ATTR=ID:user CONTENT=USERNAME
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:intro ATTR=ID:clau CONTENT=PASSWORD
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:intro ATTR=*
EVENT TYPE=CLICK SELECTOR="#logout" BUTTON=0
I'll post the JS once i have it and we will see if it worked :)

EDIT: i attempted to run it but when reaches the line: EVENT TYPE=CLICK SELECTOR="#logout" BUTTON=0 it prints the following error: the TypeError: Cannot read property 'error' of undefined, line: 8
Yeah, well, "Up" + "Up", all this part is about the 'EVENT' Mode being able to record your Actions that the 'TAG' Mode couldn't, OK, good...!
Not much I/we can say further about this part without being able to "play" with the Site/Page itself to see how it "behaves"...

I don't think I know this "the TypeError: Cannot read property 'error' of undefined, line: 8" RuntimeError, I've never seen it I think on the Versions I use myself (v8.8.2 + v8.9.7 for FF), but the 'EVENT' Mode got a bit "redesigned" when it was implemented for CR, so it could be specific to v10.0.x for CR/FF...

What I "see" from your second Script, is that your Script fills in a Login and Password, with that Login Process placed in a Frame, hum..., not very "Standard" Design, but OK, I've seen some Sites designed this way indeed..., the 'SUBMIT' Statement is probably the Click on the 'Login' Button... Then..., once logged in, you directly click using the 'EVENT' Mode on some 'logout' Element, still in the same Frame, and without "doing" anything with the "real" Site/Page, or you would have a few Statements in the "FRAME F=0" Frame, I would expect...

>>>

Then concerning the "main" Qt in your Thread, about the Scheduled Launch of your Macro, OK for the Embedded Macro in JS in some local '.html' Page, I gave you a Link to the relevant Section in the Wiki...
The Link you posted yourself about some other Wiki Page about JavaScript is not very relevant for you as it concerns the 'Scripting Interface' and the Example on that Page is indeed only relevant for IE as it involves some ActiveX Object which is IE specific...

Concerning the Link I already gave you, there were already a few Threads on the Forum about that Functionality, and which might give a bit more Info and more Examples than the Wiki Page/Section itself..., let me see if I can find them or at least one, I think the 2 or 3 different Threads are all cross-linked...
Yep, found it directly as I had bookmarked it indeed... 8) :
- How to run a macro from the command line using Chrome
- (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