Click link -> if active, stop loop

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.

Click link -> if active, stop loop

by aethanol on Fri Nov 11, 2016 12: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?
aethanol
 
Posts: 1
Joined: Thu Nov 10, 2016 11:58 pm

Re: Click link -> if active, stop loop

by chivracq on Fri Nov 11, 2016 11:05 am

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)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 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: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Click link -> if active, stop loop

by iimfun on Mon Nov 14, 2016 1: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.
iimfun
 
Posts: 201
Joined: Tue Jul 19, 2016 6:06 am

Re: Click link -> if active, stop loop

by chivracq on Mon Nov 14, 2016 10:31 am

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)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 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: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Click link -> if active, stop loop

by iimfun on Wed Nov 16, 2016 1: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!
iimfun
 
Posts: 201
Joined: Tue Jul 19, 2016 6:06 am

Re: Click link -> if active, stop loop

by chivracq on Wed Nov 16, 2016 6:51 pm

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)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 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: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Chrome

Who is online

Users browsing this forum: No registered users and 2 guests

Website Monitoring