Click link -> if active, stop loop

Discussions and Tech Support specific to the iMacros for 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
aethanol
Posts: 1
Joined: Fri Nov 11, 2016 6:58 am

Click link -> if active, stop loop

Post by aethanol » Fri Nov 11, 2016 7:54 am

Hi

I have a simple macro that clicks a link (not an actual hyperlink but a link inside a site). The link is mostly inactive but when a client comes online, it switches "on" and when it is on, clicking on it opens a sidebar chat. I run the macro on loop (clicking repeatedly the inactive link) so that when the link switches "on", it activates the chat on the next loop.

The problem is, I need to be quick when stopping the loop manually so that I don't catch a second chat on the same run.

Is there any method to make the loop stop automatically when it clicks on an active link?
chivracq
Posts: 9290
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Click link -> if active, stop loop

Post by chivracq » Fri Nov 11, 2016 6:05 pm

aethanol wrote:Hi

I have a simple macro that clicks a link (not an actual hyperlink but a link inside a site). The link is mostly inactive but when a client comes online, it switches "on" and when it is on, clicking on it opens a sidebar chat. I run the macro on loop (clicking repeatedly the inactive link) so that when the link switches "on", it activates the chat on the next loop.

The problem is, I need to be quick when stopping the loop manually so that I don't catch a second chat on the same run.

Is there any method to make the loop stop automatically when it clicks on an active link?
Hum, "CIM", read my Sig..., and try to post in the correct Sub-Forum when you open a Thread, your Qt has nothing specific to 'iMacros for CR' I would think, especially if you don't mention your FCI... (No need to duplicate...)

Yep for your Qt, use 'EVENT:FAIL_IF_FOUND' or 'MacroError()'.
- (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...
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Click link -> if active, stop loop

Post by iimfun » Mon Nov 14, 2016 8:31 am

aethanol wrote:Is there any method to make the loop stop automatically when it clicks on an active link?
Your code may be similar to the following one

Code: Select all

SET !EXTRACT_TEST_POPUP NO
SET !LOOP -99999999999

' click on your button
TAG POS=1 TYPE=BUTTON ATTR=blablabla
' extract html of your button
TAG POS=1 TYPE=BUTTON ATTR=blablabla EXTRACT=HTM

SET stopCheck EVAL("if ('{{lastHtml}}' != '__undefined__' &&  '{{lastHtml}}' != '{{!EXTRACT}}') MacroError('MACROSTOP');")
SET lastHtml {{!EXTRACT}}
SET !EXTRACT NULL
WAIT SECONDS=3
Supposed that this macro is launched when your button is inactive.
chivracq
Posts: 9290
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Click link -> if active, stop loop

Post by chivracq » Mon Nov 14, 2016 5:31 pm

iimfun wrote:
aethanol wrote:Is there any method to make the loop stop automatically when it clicks on an active link?
Your code may be similar to the following one

Code: Select all

SET !EXTRACT_TEST_POPUP NO
SET !LOOP -99999999999

' click on your button
TAG POS=1 TYPE=BUTTON ATTR=blablabla
' extract html of your button
TAG POS=1 TYPE=BUTTON ATTR=blablabla EXTRACT=HTM

SET stopCheck EVAL("if ('{{lastHtml}}' != '__undefined__' &&  '{{lastHtml}}' != '{{!EXTRACT}}') MacroError('MACROSTOP');")
SET lastHtml {{!EXTRACT}}
SET !EXTRACT NULL
WAIT SECONDS=3
Supposed that this macro is launched when your button is inactive.
Hum, trying to "educate" Users to use the Forum "a bit correctly" and let them search the Forum a bit, but never mind... :roll:

But @iimfun, I think it would be better if you stopped "advertizing" for the Negative Loop Trick that you keep posting in nearly all Script Samples you post, it is an undocumented Trick that should be used only when the "Standard" Loop Mechanism is not usable, Dev is not aware of it, it only works on FF and CR I think, and as soon as they will hear about it, I am afraid they will probably cut it to "harmonize" the Core-Code between all Versions and we won't be able to use it anymore...! :idea:
And you could argue that the more People use it, the more Users will be "screaming" if it ever gets disabled, yep, but we'll have to wait for 1 year I guess before it eventually gets reactivated in some later Release...

Hum @iimfun, and one new Thread that could use your Expertise and Thoughts rather than this "easy one" is this Thread about Sub-Scripts in CR as you know more than me on the Subject I reckon... 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...
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Click link -> if active, stop loop

Post by iimfun » Wed Nov 16, 2016 8:20 am

chivracq wrote:I think it would be better if you stopped "advertizing" for the Negative Loop Trick
Yes, sorry. I may be indeed disobedient sometimes... However it seems that my flaw doesn't matter for @aethanol at all.
chivracq wrote:new Thread that could use your Expertise and Thoughts rather than this "easy one"
Have nothing to add because you gave an explanation extensive enough. I wish the reaction was at least like "Wow! Thanks to all...". Alas!
chivracq
Posts: 9290
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Click link -> if active, stop loop

Post by chivracq » Thu Nov 17, 2016 1:51 am

iimfun wrote:
chivracq wrote:I think it would be better if you stopped "advertizing" for the Negative Loop Trick
Yes, sorry. I may be indeed disobedient sometimes... However it seems that my flaw doesn't matter for @aethanol at all.
Hum, not really about being "disobedient", I reckon you didn't know the possible "Consequences" about that "secret" Trick, I'm just trying to preserve the "Interest" of all/most Users, even if I don't really care for myself as I am using some "older" Version of iMacros for FF (v8.8.2) that I intend to stick to as long as I can and to which I am able to add some new Features myself that could seduce me from some later Version(s), or if I ever updated to some "later" Version, I would be able to revert some Functionality to what it previously was if I preferred the previous Behaviour...
See the following Thread if you don't understand what I'm talking about:
- Extend Imacros with new commands?
Sorry @OP, has nothing to do with your current Thread, this is pure "pollution", ah-ah...!
iimfun wrote:
chivracq wrote:new Thread that could use your Expertise and Thoughts rather than this "easy one"
Have nothing to add because you gave an explanation extensive enough. I wish the reaction was at least like "Wow! Thanks to all...". Alas!
Ah OK, I referred to 2 Threads of yours in that Thread and I thought you might have some more "Creative" Thinking about the Subject... 8)

And Tja, "Wow! Thanks to all..." is part of my "Standards" for "using the Forum a bit correctly"... :shock:
Hum, and we'll see if @aethanol mentions their FCI and follows up on their Thread, ah-ah...! :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...
Post Reply