EVAL for random clicks

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
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
Reacher
Posts: 5
Joined: Sun Aug 23, 2015 9:25 pm

EVAL for random clicks

Post by Reacher » Sun Sep 18, 2016 6:24 pm

Hello, I need some help with this macro I'm trying to get right.
Let's say that I need a macro that would randomly click or not click on a button.

I've found some instruction in this forum but I can't make it work. For sure I'm missing something.

Code: Select all

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAB CLOSEALLOTHERS
SET !ERRORIGNORE NO

SET u_0_i "Continue"
SET u_0_i EVAL("(Math.floor(2*Math.random()) == 0) ? 'No such button!' : '{{Continue}}';")
SET !TIMEOUT_STEP 0
URL GOTO=https://www.pinterest.com/
TAG POS=1 TYPE=BUTTON FORM=NAME:NoFormName ATTR=TXT:{{Continue}}
SET !TIMEOUT_STEP 6
Any help would be appreciated, thanks.


URL GOTO=https://www.pinterest.com/
TAG POS=1 TYPE=BUTTON FORM=NAME:NoFormName ATTR=TXT:Continue
VERSION BUILD=9030808 - Firefox 48.0.2 - Windows 10
chivracq
Posts: 9309
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL for random clicks

Post by chivracq » Sun Sep 18, 2016 10:41 pm

Reacher wrote:

Code: Select all

VERSION BUILD=9030808 - 
Firefox 48.0.2 - 
Windows 10
Hello, I need some help with this macro I'm trying to get right.
Let's say that I need a macro that would randomly click or not click on a button.

I've found some instruction in this forum but I can't make it work. For sure I'm missing something.

Code: Select all

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAB CLOSEALLOTHERS
SET !ERRORIGNORE NO

SET u_0_i "Continue"
SET u_0_i EVAL("(Math.floor(2*Math.random()) == 0) ? 'No such button!' : '{{Continue}}';")
SET !TIMEOUT_STEP 0
URL GOTO=https://www.pinterest.com/
TAG POS=1 TYPE=BUTTON FORM=NAME:NoFormName ATTR=TXT:{{Continue}}
SET !TIMEOUT_STEP 6
Any help would be appreciated, thanks.

Code: Select all

URL GOTO=https://www.pinterest.com/
TAG POS=1 TYPE=BUTTON FORM=NAME:NoFormName ATTR=TXT:Continue
Yep but you are completely messing up with the Use of Variables with iMacros, a Var has a Name and a Value attributed to it and you are completely mixing them up, have a look at the Wiki about Variables and the underlying Links...

And, hum, you sound like a Beginner, but the "? / :" Syntax you are using in your 'EVAL()' Statement is quite advanced, probably from some Post by @iimfun who's the only one on this Forum to use it, I had never heard of it until 2 months ago for myself, you should find some "more classic Examples" of 'EVAL()' with "IF ELSE" and make sure you understand how it works before you start using this advanced/simplified "? / :" Syntax... :idea:
- (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...
Reacher
Posts: 5
Joined: Sun Aug 23, 2015 9:25 pm

Re: EVAL for random clicks

Post by Reacher » Mon Sep 19, 2016 7:49 pm

Solved, just had to replace those u_0_i with continue.
VERSION BUILD=9030808 - Firefox 48.0.2 - Windows 10
chivracq
Posts: 9309
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL for random clicks

Post by chivracq » Wed Sep 21, 2016 2:06 am

Reacher wrote:Solved, just had to replace those u_0_i with continue.
OK, good, you hopefully/obviously understood a bit the part I meant about completely "mixing/messing up" with the Vars, glad it now works for you (and mini-Compliment btw...! => Quick Learner hopefully...!) (even if to be honest, it is a complete Beginner's Concept, first time honestly we had sbd on the Forum asking such a naive Qt about the "Variables" Concept, sorry...!), though I would be surprised if you really understood the second part about the Syntax... You should only use Code that you fully understand, that's how "we" hack you...! :idea:
- (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...
zhedielj
Posts: 18
Joined: Wed Apr 02, 2014 3:08 pm

Re: EVAL for random clicks

Post by zhedielj » Mon Sep 26, 2016 2:13 am

Reacher wrote:Solved, just had to replace those u_0_i with continue.
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAB CLOSEALLOTHERS
SET !ERRORIGNORE NO

SET continue "Continue"
SET continue EVAL("(Math.floor(2*Math.random()) == 0) ? 'No such button!' : '{{Continue}}';")
SET !TIMEOUT_STEP 0
URL GOTO=https://www.pinterest.com/
TAG POS=1 TYPE=BUTTON FORM=NAME:NoFormName ATTR=TXT:{{Continue}}
SET !TIMEOUT_STEP 6

I replaced the u_0_i with continue, but still get error message "element BUTTON specified by TXT:Continue was not found, line: 10 (Error code: -921)"
Post Reply