PROMPT Messagebox - Yes - No - Cancel (end)

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
i_macro_user
Posts: 76
Joined: Sun Dec 02, 2012 5:28 pm

PROMPT Messagebox - Yes - No - Cancel (end)

Post by i_macro_user » Wed Nov 13, 2013 11:38 am

Hallo,

Messagebox - Yes - No - Cancel (end)

(1)

If a message box (PROMPT ... or input box) appears, then this appears exclusively modal. This means that it is in the foreground, without that you can stop the script at this point in the iMacros toolbar.

What to do?

(2)

How can I get a message box (PROMPT) show, in which it, "No", "Cancel" is the "Yes" button?

Is this already possible or scheduled for a later version?

Is there a workaround for the problem described?

How then is evaluated which button "Yes", "No", "Cancel" was clicked?

Best regards



Messagebox - Ja - Nein - Abbrechen (Ende)
Wenn eine Messagebox (PROMPT ... bzw. Eingabebox) erscheint, dann erscheint diese ausschließlich modal. Das bedeutet, dass sie im Vordergrund ist, ohne dass man das Skript an dieser Stelle in der iMacros-Leiste stoppen kann.
Was tun?
Wie kann ich eine Messagebox (PROMPT) anzeigen, bei denen es die Button "Ja", "Nein", "Abbrechen" gibt?
Ist das bereits jetzt möglich oder für eine spätere Version vorgesehen?
Gibt es einen Workaround für das beschriebene Problem?
Wie erfolgt dann die Auswertung, welcher Button "Ja", "Nein", "Abbrechen" geklickt wurde?
Hum ... Only professional answers are helpful
Hum ... No complete quotations - limit to the essentials
Hum ... Can we get along in this forum without personal attacks?
Hum ... I use automatic translations
Yes ... I am iMacros beginners :-)
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by Tom, Tech Support » Thu Nov 14, 2013 1:49 pm

Hi i_macro_user,

Here is one way to do it currently:

Code: Select all

SET !VAR1 NULL
PROMPT "Do you want to abort the macro? Y/N" !VAR1 N
SET !VAR2 EVAL("var response = \"{{!VAR1}}\"; if (response.toUpperCase() == \"Y\") MacroError(\"User aborted\"); if (response.length == 0 || response == \"NULL\") response = \"Cancel\"; response;")
PROMPT "You pressed {{!VAR2}}"
Regards,

Tom, iMacros Support
i_macro_user
Posts: 76
Joined: Sun Dec 02, 2012 5:28 pm

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by i_macro_user » Wed Dec 18, 2013 12:34 pm

Hallo Tom

That's a good idea. Now I need a query whether variable 2 contains the value "y" or "n" to as to be able to perform further steps in accordance with "Yes" or "No".

On the internet I found nothing.

http://wiki.imacros.net/Command_Reference

Works with iMacros Anchor links or subroutines or how to solve if - then - problems?

best regards



Das ist eine gute Idee. Nun brauche ich noch eine Abfrage, ob Variable 2 den Wert "y" oder "n" enthält, um denn weitere Schritte entsprechend "Yes" oder "No" ausführen zu können.
Auf der Internetseite fand ich nichts.
Arbeitet iMacros mit Sprungmarken oder Unterprogrammen oder wie löst man wenn - dann - Probleme?
Hum ... Only professional answers are helpful
Hum ... No complete quotations - limit to the essentials
Hum ... Can we get along in this forum without personal attacks?
Hum ... I use automatic translations
Yes ... I am iMacros beginners :-)
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by Tom, Tech Support » Wed Dec 18, 2013 12:47 pm

Hi i_macro_user,

The iMacros macro language does not provide the ability to do conditional (if/then) branching. For this you need to put your logic into a custom script and use the scripting interface to control iMacros.

Please see this FAQ for more information.
Regards,

Tom, iMacros Support
i_macro_user
Posts: 76
Joined: Sun Dec 02, 2012 5:28 pm

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by i_macro_user » Sat May 23, 2015 7:07 pm

Hallo,

some times later.

New Version of iMacros - is there a better solution for this problem?

I get only the Message "you pressed Cancel". But the script don't stop.

Please give me a possibility to stop the Script, if I pressed Cancel.

I don't understand the FAQ - I don't know, how can I stop the Script, if I pressed Cancel.

SET !ERRORIGNORE NO

But I don't get the error: "User aborted"
from
SET !VAR2 EVAL("var response = \"{{!VAR1}}\"; if (response.toUpperCase() == \"Y\") MacroError(\"User aborted\");

the script don't stop.

best regards
Hum ... Only professional answers are helpful
Hum ... No complete quotations - limit to the essentials
Hum ... Can we get along in this forum without personal attacks?
Hum ... I use automatic translations
Yes ... I am iMacros beginners :-)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by chivracq » Sun May 24, 2015 3:51 pm

i_macro_user wrote:Hallo,

some times later.

New Version of iMacros - is there a better solution for this problem?

I get only the Message "you pressed Cancel". But the script don't stop.

Please give me a possibility to stop the Script, if I pressed Cancel.

I don't understand the FAQ - I don't know, how can I stop the Script, if I pressed Cancel.

SET !ERRORIGNORE NO

But I don't get the error: "User aborted"
from
SET !VAR2 EVAL("var response = \"{{!VAR1}}\"; if (response.toUpperCase() == \"Y\") MacroError(\"User aborted\");

the script don't stop.

best regards
iMacros 10, Windows 8 / 64, I use the iMacros Browser (not MSIE) - sometimes Firefox - every time the last version - 2014-12-10
Not impressed by your Follow-up, 1½ years later...

And mentioning your FCI is a good thing (otherwise I wouldn't answer your Thread...) but putting it in your Sig is not the best place as you only have one global Sig for all your Msg's and it makes your Msg's from 1½ years ago and in 1½ years a bit confusing... :idea:

But I tested Tom's Code and it works fine for me, but the Macro stops only if the User types "y" or "Y" and then presses 'OK' (and not 'Cancel').

And this made me discover a little Bug in my Opinion, that when looping the Macro, if '!ERRORIGNORE' is used (set to 'YES'), that Setting is global and it is not reset to 'NO' at the end of each Loop, meaning you are indeed required to set '!ERRORIGNORE' to 'NO' just before the 'EVAL()' with 'MacroError()'...

I changed Tom's Code a little bit to "my preferred" Notation as I didn't get it to work directly because of the '!ERRORIGNORE' mini-Problem, but both Statements work fine...:

Code: Select all

SET !ERRORIGNORE NO

SET !VAR1 NULL
PROMPT "Do you want to abort the macro? Y/N" !VAR1 N
'SET !VAR2 EVAL("var response = \"{{!VAR1}}\"; if (response.toUpperCase() == \"Y\") MacroError(\"User aborted\"); if (response.length == 0 || response == \"NULL\") response = \"Cancel\"; response;")
SET !VAR2 EVAL("var response='{{!VAR1}}'; if(response.toUpperCase()=='Y') {MacroError(\"User aborted\");}; if(response.length==0 || response=='NULL') {response='Cancel';}; response;")
PROMPT "You pressed {{!VAR2}}"

SET !ERRORIGNORE YES
(Tested on iMacros for FF v8.8.2, Pale Moon v24.6.2 (=FF31), Win7-x64.)
- (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...
i_macro_user
Posts: 76
Joined: Sun Dec 02, 2012 5:28 pm

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by i_macro_user » Tue May 26, 2015 7:26 pm

Dear friend,

I used another solution without iMacros over one year, because I hope, simply function as dialog with yes and cancel will be in the next version.

I saw no new version with this function ... and I ask again.

Thx for your help - I try it today :-)

Result: :-(

I try it in iMaros 10 and in inMacros for Firefox / Windows 8 /64.

I click cancel - and I got the Message from the Script-Line:

PROMPT "You pressed {{!VAR2}}"

"You pressed N"

No error, no abort, no cancel ... the script don't stop, if I click cancel.

:?: :?: :?:

idea - I used the german Version - Button "Cancel" = "Abbrechen"
I think no - I replace all Cancel to Abbrechen, an I got the Message:

"You pressed N"

best regards
Hum ... Only professional answers are helpful
Hum ... No complete quotations - limit to the essentials
Hum ... Can we get along in this forum without personal attacks?
Hum ... I use automatic translations
Yes ... I am iMacros beginners :-)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by chivracq » Tue May 26, 2015 9:02 pm

I already gave you the Answer:
But I tested Tom's Code and it works fine for me, but the Macro stops only if the User types "y" or "Y" and then presses 'OK' (and not 'Cancel').
The Question presented by the Prompt is "Do you want to abort the macro? Y/N"
=> If you want to abort the Macro, you need to press 'Y' or 'y' (Tom took care of the Case Sensitivity, look a little bit at the 'EVAL()' Statement to understand as well what it is doing...) and then click on 'OK'.... If you click on 'Cancel', that means "Oops, mistake, go away stupid Prompt, I don't want you to do anything...!" => 'Cancel' = Cancel the PROMPT...! (... And do nothing...)

The iMacros 'PROMPT' only has 'OK'/'Cancel', there is no 'Yes'/'No' or 'Yes'/'No'/'Cancel'..., so 'Yes' takes an Action, and 'Cancel' does nothing...
It is possible to reverse the 'EVAL()' Statement if you want 'Cancel' actually to stop the Macro but you need to change the Question as well..., otherwise it's not logical...
- (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...
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by Tom, Tech Support » Wed May 27, 2015 10:06 am

i_macro_user wrote:I try it in iMaros 10 and in inMacros for Firefox / Windows 8 /64.

I click cancel - and I got the Message from the Script-Line:

PROMPT "You pressed {{!VAR2}}"

"You pressed N"
When I run my original code above using iMacros 10.4 in the iMacros Browser or iMacros for IE, the result I get when clicking the Cancel button is "You pressed Cancel".

However, doing the same in iMacros for Firefox yields "You pressed N".

The reason for the difference is because iMacros for Firefox assigns the default value (the third parameter to the PROMPT command) to the input variable *even if* you click Cancel, whereas iMacros for IE does not (in this case it assigns an empty/null value to !VAR1).

You can see this for yourself by adding PROMPT {{!VAR1}} after the first PROMPT command.

The workaround for iMacros for Firefox would be to not specify a default value in the prompt command:

Code: Select all

PROMPT "Do you want to abort the macro? Y/N" !VAR1
I will log this as a consistency issue in iMacros for Firefox. In my opinion, pressing the Cancel button should not perform the variable assignment.
Regards,

Tom, iMacros Support
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by chivracq » Wed May 27, 2015 10:36 am

Yep, that's indeed the Behaviour I observed..., but I wasn't shocked...! (But I only tested on iMacros for FF (v8.8.2).)

>>>

Nice as well if the Developer(s) "work" on the 'PROMPT' Command would be to add an Enhancement Request for an extra Parameter to define the Prompt Type:
- OK (Default if no Input Var is defined.)
- OK/Cancel (Default if an Input Var is defined.)
- YES/NO
- YES/NO/Cancel
(with OK/Cancel being the Default if nothing is specified...)

>>>

And nice as well would be to have another Parameter when looping a Macro to be able to specify when the PROMPT will be triggered:
- All Loops (Default).
- Only First Loop.
- Only Last Loop (-1).
- Only Loop n.
- Only Loops 3,4,5,10-15,*2*.

>>>

And while the Developer(s) look(s) at 'PROMPT', another thing related to PROMPT which is not working is this bit from the Wiki on 'URL GOTO':
Using Javascript

The URL can also call Javascript functions that are either defined in this line or are embedded in the page (V6.22 and later):

Code: Select all

URL GOTO=javascript:alert("TEST");
This prevents from making Conditional PROMPT's with 'EVAL()'...
- (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...
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by Tom, Tech Support » Wed May 27, 2015 11:40 am

chivracq wrote:And while the Developer(s) look(s) at 'PROMPT', another thing related to PROMPT which is not working is this bit from the Wiki on 'URL GOTO':

Using Javascript

The URL can also call Javascript functions that are either defined in this line or are embedded in the page (V6.22 and later):

Code: Select all
URL GOTO=javascript:alert("TEST");


This prevents from making Conditional PROMPT's with 'EVAL()'...
I was unaware of this until now. The reason this no longer works is because iMacros thinks it is an unhandled dialog and returns error code -1450. Running the same code in iMacros browser/IE successfully displays the alert dialog. I have logged this for further investigation by the development team.

As far as the other suggestions, they are nice, but I would not hold your breath for those unless we start getting many other similar requests. :cry:
Regards,

Tom, iMacros Support
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by chivracq » Wed May 27, 2015 12:46 pm

Tom, Tech Support wrote:
chivracq wrote:And while the Developer(s) look(s) at 'PROMPT', another thing related to PROMPT which is not working is this bit from the Wiki on 'URL GOTO':

Using Javascript

The URL can also call Javascript functions that are either defined in this line or are embedded in the page (V6.22 and later):

Code: Select all
URL GOTO=javascript:alert("TEST");

This prevents from making Conditional PROMPT's with 'EVAL()'...
I was unaware of this until now. The reason this no longer works is because iMacros thinks it is an unhandled dialog and returns error code -1450. Running the same code in iMacros browser/IE successfully displays the alert dialog. I have logged this for further investigation by the development team.
It's been broken already for 2 or 3 years, from iMacros for FF v8.x, I think..., I've reported/mentioned it already several times in different Threads... But good that you are aware of it now...

Oh...!, and it's not only 'alert()' but the 2 or 3 other similar JavaScript Functions triggering DialogBoxes that are impacted as well, I don't remember their Names...
Tom, Tech Support wrote:As far as the other suggestions, they are nice, but I would not hold your breath for those unless we start getting many other similar requests. :cry:
Yep, I know, don't worry, I only hold my breath when I'm under water, if I had been holding my breath since I've asked for a '!LOOP_MAX' Built-in Variable to be implemented and for several Bugs pertaining to the EVENT Mode to be solved, I wouldn't be posting on the Forum anymore since a long time... :shock:

And once "URL GOTO=javascript:alert("TEST");" works (again), I will be able to find (easier) Workarounds for all the Conditional Prompts (in pure .iim)... (I already have one but it's not very handy...)

I only mentioned these Enh-Req's for 'PROMPT' if the Developer(s) is/are going to dig into the Code for 'PROMPT', then it's easier to tackle several Tasks (if nothing new gets broken...!) because 50% of the Effort has already been done...
- (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...
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by Tom, Tech Support » Wed May 27, 2015 7:45 pm

Speaking of EVENT mode, I'll let you in on a little secret: EVENT mode is currently being implemented for iMacros for IE and iMacros browser. I made the devs aware of your forum thread giving feedback, and hoping that the iMacros-FX and iMacros-IE teams collaborate to make enhancements and keep the functionality consistent between iMacros versions. It might not happen right away, but over time it should improve.
Regards,

Tom, iMacros Support
i_macro_user
Posts: 76
Joined: Sun Dec 02, 2012 5:28 pm

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by i_macro_user » Tue Jun 02, 2015 7:03 pm

@chivracq

many thanks - now I understand - only Y is possible in this construction

:-)

Manchmal sieht man den Wald vor lauter Bäumen nicht :-)
Hum ... Only professional answers are helpful
Hum ... No complete quotations - limit to the essentials
Hum ... Can we get along in this forum without personal attacks?
Hum ... I use automatic translations
Yes ... I am iMacros beginners :-)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: PROMPT Messagebox - Yes - No - Cancel (end)

Post by chivracq » Tue Dec 22, 2015 3:38 am

i_macro_user wrote:@chivracq

many thanks - now I understand - only Y is possible in this construction :-)

Manchmal sieht man den Wald vor lauter Bäumen nicht :-)
Yep, you're welcome... :D (Late reply, though I had seen your Reply at the time you had posted it...)

Don't blame the Trees though, they are your best Friends...! 8)
There is some Tribe somewhere in Africa I think, or somewhere in the Amazon maybe, well in some place on this Planet where there are Elephants...!, where they live in some very dense Forest Environment and never see any further than 20m away..., and when they happen to find some open space and see an Elephant at 200m, they won't recognize it as an Elephant but will think it's a Fly...! or any tiny Beastie, because of the Distance...

>>>

OK, reason I checked this Thread and want to bump it:
Some other User/Thread that would benefit from the EnhReq I posted about '!LOOP':
- Re: Using a variable to set the datasource name.
(The Thread Title doesn't sound much like it is really related but it is, it came as a follow-up Question to the Original Question, and I referred in that Thread to this current Thread/EnhReq...)
MattBuck wrote:I was afraid you were going to tell me that. :cry:

This is exactly what would benefit me:
And nice as well would be to have another Parameter when looping a Macro to be able to specify when the PROMPT will be triggered:
- All Loops (Default).
- Only First Loop.
- Only Last Loop (-1).
- Only Loop n.
- Only Loops 3,4,5,10-15,*2*.
How do we get this "bumped" so that it appears in the next version of iMacros? Or maybe, it was included in the latest release (Ver. 11) and we just don't know it yet (fortunately, the company that I work for just renewed our support agreement and I can upgrade :D ).

:idea: Crossing my fingers that if it isn't in Ver. 11 that it is included in Ver. 11.1 :idea:

For now, I may have to rely on the users editing the script {shudders at the thought} until another solutions presents itself.
The User I quote will probably bump the Thread as well, or I will strongly/nicely entice him to do so, ah-ah...!! :twisted:
- (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