Display Number of button Pushes

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
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
achaney
Posts: 11
Joined: Sun Nov 09, 2014 6:17 am

Display Number of button Pushes

Post by achaney » Sun Nov 09, 2014 6:30 am

So I am trying to display the number of times the macro clicks a button, but for the life of me can not find a way.

Example:
Forum software locks users after so many invalid attempts (posting, logging on, whatever). I want to go in and unlock all the users, but want to know how many users were locked. The first time I go to unlock there are 4 users locked. The second time I go there are 3. At the end I want it to display that I unlocked 4 users the first time and 3 the second time.


EX (Bad) Code:
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1
SET !VAR2 1
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1
SET !VAR2 2
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1
SET !VAR2 3
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1
SET !VAR2 4
Prompt Removed<SP>{{!VAR2}}<SP>Account<SP>Locks.

But of course that will not work because if there is less than 4 locks, it will error or worse yet there are more than 4 and it does not unlock everybody. And I can't use SET !ERRORIGNORE as that would just always make it the highest variable. I have a feeling it is something easier than I am making it, but for the life of me I can't figure it out. Any help would be greatly appreciated.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Display Number of button Pushes

Post by chivracq » Sun Nov 09, 2014 8:42 pm

achaney wrote:So I am trying to display the number of times the macro clicks a button, but for the life of me can not find a way.

Example:
Forum software locks users after so many invalid attempts (posting, logging on, whatever). I want to go in and unlock all the users, but want to know how many users were locked. The first time I go to unlock there are 4 users locked. The second time I go there are 3. At the end I want it to display that I unlocked 4 users the first time and 3 the second time.

EX (Bad) Code:

Code: Select all

TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1
SET !VAR2 1
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1
SET !VAR2 2
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1
SET !VAR2 3
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1
SET !VAR2 4
Prompt Removed<SP>{{!VAR2}}<SP>Account<SP>Locks.
But of course that will not work because if there is less than 4 locks, it will error or worse yet there are more than 4 and it does not unlock everybody. And I can't use SET !ERRORIGNORE as that would just always make it the highest variable. I have a feeling it is something easier than I am making it, but for the life of me I can't figure it out. Any help would be greatly appreciated.
CIM...! :mrgreen:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
achaney
Posts: 11
Joined: Sun Nov 09, 2014 6:17 am

Re: Display Number of button Pushes

Post by achaney » Sun Nov 09, 2014 11:05 pm

VERSION BUILD=8850919
Firefox (latest Version - 33.0.2)
Win 7
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Display Number of button Pushes

Post by chivracq » Mon Nov 10, 2014 1:03 am

achaney wrote:VERSION BUILD=8850919
Firefox (latest Version - 33.0.2)
Win 7
Good... :D

OK, to answer your Question, the most straightforward way would be to have a short .iim Macro removing 1 Lock that would loop, but it's not possible to have a Conditional Prompt (or at least I haven't found a way to do so...) as the 'URL GOTO' Syntax is buggy with 'alert()' and doesn't work (although it's advertised in the Wiki and having a Hard Prompt would be annoying because you would get the Prompt at each Loop... And it's not possible to use 'iimDisplay()' like in .js Scripts (or at least again, I haven't found a way to get it to work...)...
Making your whole Script in JavaScript is a good option, but I tend to try to avoid JavaScript myself...

Possible is to have the Macro loop for 1 Lock and once there is no more 'Unlock' Button, to conditionally launch a second mini-Macro only handling the Prompt using the "'URL GOTO=imacros://run/?m=Prompt.iim" Syntax.
Passing the Loop Counter from one .iim Script as an Argument to another one is possible I think though I've never done it, but I would go for the easy Solution to use the Clipboard to store it temporarily, knowing that you cannot do any Copy&Paste while your Script is running!

But I think the best Solution is to use 'EVAL()' with MacroError with stg like:

Code: Select all

TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1
WAIT SECONDS=1
'Check if there is a next Account to unlock or abort the Loop:
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_lock ATTR=NAME:submit1 EXTRACT=TXT
SET Unlocked EVAL("var s=\"{{!EXTRACT}}\"; if(s=='#EANF#') {MacroError(\"Removed {{!LOOP}} Account Locks.\");} else s;")
(Tested on iMacros v8.8.2 for FF, Pale Moon v24.6.2 (=FF31), Win7-64.)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
achaney
Posts: 11
Joined: Sun Nov 09, 2014 6:17 am

Re: Display Number of button Pushes

Post by achaney » Mon Nov 10, 2014 3:04 am

Tested, Does not work. All it does is display the text of the unlock button and then end...does not continue to unlock accounts.
achaney
Posts: 11
Joined: Sun Nov 09, 2014 6:17 am

Re: Display Number of button Pushes

Post by achaney » Mon Nov 10, 2014 3:13 am

Maybe It would be easier to post my current code that removes one unlock and tickets it.

Code: Select all

VERSION BUILD=8850919 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=A ATTR=TXT:Bio<SP>Data<SP>Unlock
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_biodata ATTR=NAME:submit1
TAB T=2
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_WebUserNameTextBox CONTENT=ACTickets
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_FindCustomerButton
TAG POS=1 TYPE=A ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_CreateTicketHyperLink
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ContactTypesDropDown CONTENT=%N
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ProductFamilyDropDown CONTENT=%FORUM
TAG POS=1 TYPE=TEXTAREA FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_DescriptionTextBox CONTENT=Removed<SP>Biodata<SP>Lock

Now what my goal is is to get it to repeat the step

Code: Select all

TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_biodata ATTR=NAME:submit1
Until there are no more buttons to push. And each time it does the unlock to increase a variable by one so then the final line would be something like

Code: Select all

TAG POS=1 TYPE=TEXTAREA FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_DescriptionTextBox CONTENT=Removed<SP>{{!VAR1}}<SP>Biodata<SP>Lock(s)
That way I can ticket how many unlocks were done when I ran the macro.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Display Number of button Pushes

Post by chivracq » Tue Nov 11, 2014 12:32 am

achaney wrote:Tested, Does not work. All it does is display the text of the unlock button and then end...does not continue to unlock accounts.
Yep, of course, you need to add "SET !EXTRACT_TEST_POPUP NO" like mentioned in the Extract Test Popup and in the Wiki...!

My Script should work if you loop it once you are on the right Page... ("abort the Loop" means you are looping the Script...!)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
achaney
Posts: 11
Joined: Sun Nov 09, 2014 6:17 am

Re: Display Number of button Pushes

Post by achaney » Thu Nov 13, 2014 8:47 pm

Current Code:

Code: Select all

VERSION BUILD=8850919 RECORDER=FX
SET !EXTRACT_TEST_POPUP NO
TAB T=1
SET !LOOP 10
TAG POS=1 TYPE=A ATTR=TXT:Bio<SP>Data<SP>Unlock
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_biodata ATTR=NAME:submit1
WAIT SECONDS=1
'Check if there is a next Account to unlock or abort the Loop:
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_biodata ATTR=NAME:submit1 EXTRACT=TXT
SET Unlocked EVAL("var s=\"{{!EXTRACT}}\"; if(s=='#EANF#') {MacroError(\"Removed {{!LOOP}} Account Locks.\");} else s;")
TAB T=2
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_WebUserNameTextBox CONTENT=ACTickets
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_FindCustomerButton
TAG POS=1 TYPE=A ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_CreateTicketHyperLink
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ContactTypesDropDown CONTENT=%None
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ProductFamilyDropDown CONTENT=%FORUM
TAG POS=1 TYPE=TEXTAREA FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_DescriptionTextBox CONTENT=Removed<SP>{{!VAR2}}<SP>Biodata<SP>Lock
All it does is remove one lock and then go to ticket it. It never loops...am I missing something?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Display Number of button Pushes

Post by chivracq » Fri Nov 14, 2014 12:34 pm

achaney wrote:Current Code:

Code: Select all

VERSION BUILD=8850919 RECORDER=FX
SET !EXTRACT_TEST_POPUP NO
TAB T=1
SET !LOOP 10
TAG POS=1 TYPE=A ATTR=TXT:Bio<SP>Data<SP>Unlock
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_biodata ATTR=NAME:submit1
WAIT SECONDS=1
'Check if there is a next Account to unlock or abort the Loop:
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_biodata ATTR=NAME:submit1 EXTRACT=TXT
SET Unlocked EVAL("var s=\"{{!EXTRACT}}\"; if(s=='#EANF#') {MacroError(\"Removed {{!LOOP}} Account Locks.\");} else s;")
TAB T=2
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_WebUserNameTextBox CONTENT=ACTickets
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_FindCustomerButton
TAG POS=1 TYPE=A ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_CreateTicketHyperLink
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ContactTypesDropDown CONTENT=%None
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ProductFamilyDropDown CONTENT=%FORUM
TAG POS=1 TYPE=TEXTAREA FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_DescriptionTextBox CONTENT=Removed<SP>{{!VAR2}}<SP>Biodata<SP>Lock
All it does is remove one lock and then go to ticket it. It never loops...am I missing something?
Ah-ah...!, sorry, nearly funny... :oops:

I don't know what Value you put in the 'Repeat Macro / Max' Field, but because of your strange "SET !LOOP 10", your Loop will start at "10"..., so if you put any Value <=10, your Script will not loop at all, and if you put for example "11", your Script will only loop twice... I reckon you should use "SET !LOOP 1"...

There is a Trick BTW where you can hard code the Number of Loops in your Macro and just use the 'Play' Button, if you want to loop your Macro 10 times for example:

Code: Select all

SET !LOOP -8
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
achaney
Posts: 11
Joined: Sun Nov 09, 2014 6:17 am

Re: Display Number of button Pushes

Post by achaney » Sat Nov 15, 2014 1:49 am

Code: Select all

VERSION BUILD=8850919 RECORDER=FX
PROMPT "Please enter Student Username" !VAR1
SET !EXTRACT_TEST_POPUP NO
TAB T=3
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/admin/user_updater.php ATTR=NAME:username CONTENT={{!VAR1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/admin/user_updater.php ATTR=*
TAG POS=2 TYPE=INPUT:SUBMIT FORM=ACTION:user_edit.php ATTR=*
TAG POS=1 TYPE=A ATTR=TXT:Bio<SP>Data<SP>Unlock
SET !LOOP 1
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_biodata ATTR=NAME:submit1
WAIT SECONDS=1
'Check if there is a next Account to unlock or abort the Loop:
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:form_biodata ATTR=NAME:submit1 EXTRACT=TXT
SET Unlocked EVAL("var s=\"{{!EXTRACT}}\"; if(s=='#EANF#') {MacroError(\"Removed {{!LOOP}} Account Locks.\");} else s;")
TAB T=2
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_WebUserNameTextBox CONTENT={{!VAR1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_FindCustomerButton
TAG POS=1 TYPE=A ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_CreateTicketHyperLink
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ContactTypesDropDown CONTENT=%P
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ProductFamilyDropDown CONTENT=%KFE
TAG POS=1 TYPE=TEXTAREA FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_DescriptionTextBox CONTENT=Removed<SP>{{!VAR2}}<SP>Biodata<SP>Lock

Still just removes one lock and goes to ticket it. There were 5 unlocks on the page and once it was finished there were 4 and the ticket says "Removed undefined Biodata Lock". My Repeat Macro setting is the default Current: 1 Max:3. The SET !LOOP 1 (and before SET !LOOP 10) I had added because you had said "My Script should work if you loop it once you are on the right Page..." which I thought that is what SET !LOOP n does?? Again thank you for all your assistance!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Display Number of button Pushes

Post by chivracq » Sat Nov 15, 2014 11:04 am

Hum, OK..., difficult anyway to be very precise without being able to play myself with the Page(s)..., but hum, next thing to investigate, I find the Tab Navigation in your Macro a bit strange...:
Because, you obviously already have 3 Tabs open, you start your Macro from Tab1, you don't do anything on Tab1 and you ask your Macro to jump straight away to Tab3, do some Processing, then go (back) to Tab2, do some Processing and the Macro ends there, on Tab2... But at the next Loop, iMacros considers Tab2 like being Tab1, and when calling "TAB T=3", the Macro will jump to Tab4 (and Tab3), then at the 3rd Loop, to Tab5 (and Tab4), and so on...
You should organize your Tabs which are already open before you start your Macro a bit differently, do some Processing on Tab1, then on Tab2, then go back to Tab1 at the end of your Macro so that Tab1 is really Tab1 for the next Loop...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply