If-confirmed multiple questions/checkboxes

chaoscreater

Active member
I have a macro that uses multiple if-confirmed clauses and so I'll get multiple pop-up boxes asking for different questions. For example, the popup box will ask me if I want to open Spotify and if yes, it will launch Spotify. If I choose no, it will ask me if I want to open the native Music app instead. Another example is that I will get asked if I want to open Google Maps, if not then it will ask if I want to open Waze and if not, it'll ask if I want to open Here Maps, etc.

It would be so much easier if I could get a single diaglog box with multiple options. I can check the ones I want in a tickbox and then it will store the answers into a variable and then I can create my actions using the variables.
 

Dm114

Well-known member
I have a macro that uses multiple if-confirmed clauses and so I'll get multiple pop-up boxes asking for different questions. For example, the popup box will ask me if I want to open Spotify and if yes, it will launch Spotify. If I choose no, it will ask me if I want to open the native Music app instead. Another example is that I will get asked if I want to open Google Maps, if not then it will ask if I want to open Waze and if not, it'll ask if I want to open Here Maps, etc.

It would be so much easier if I could get a single diaglog box with multiple options. I can check the ones I want in a tickbox and then it will store the answers into a variable and then I can create my actions using the variables.
If you only have 2 options, you can use a boolean variable with 'User prompt' option. If you have up to 3 options you can use 'Option dialog' which will show up to 3 buttons to run 3 different macros.
 

chaoscreater

Active member
If you only have 2 options, you can use a boolean variable with 'User prompt' option. If you have up to 3 options you can use 'Option dialog' which will show up to 3 buttons to run 3 different macros.
But both requires you to create a separate macro for each action? This can become messy and hard to manage...
 

420

Active member
But both requires you to create a separate macro for each action? This can become messy and hard to manage...

you could use a set variable action like Dm114 said with the user prompt, but instead of a boolean you can use an integer/string variable. (this way you can have unlimited different options)

if you want you can put something like this in the user prompt description that will be shown to you;

press 1 for spotify
press 2 for native music app

and then you just follow that up with an if clause that checks if that variable = 1 open spotifiy

else if that variable = 2 open native music app

and so on, this way you can keep it all in one macro.
 

chaoscreater

Active member
you could use a set variable action like Dm114 said with the user prompt, but instead of a boolean you can use an integer/string variable. (this way you can have unlimited different options)

if you want you can put something like this in the user prompt description that will be shown to you;

press 1 for spotify
press 2 for native music app

and then you just follow that up with an if clause that checks if that variable = 1 open spotifiy

else if that variable = 2 open native music app

and so on, this way you can keep it all in one macro.
hmm not sure I understand....

If I add the "Run Macro" action and pick User Prompt, the next step requires me to pick a category. I can't choose "set variable", which is a separate action task.

Is there an example screenshot you can share with me?
 

420

Active member
hmm not sure I understand....

If I add the "Run Macro" action and pick User Prompt, the next step requires me to pick a category. I can't choose "set variable", which is a separate action task.

Is there an example screenshot you can share with me?
i'm not sure where you got the "run macro" from, you should add a "set variable" action and then pick "user prompt" for that, then you just press ok and it let's you set a title/description. ill add a screenshot, but i don't think you will need it.

also i said you can use a string or integer variable and this is true, but you should probably go for an integer (not sure if it's the same on all phones but if i pick integer i get a "numpad" keyboard right away while a string variable gives me a normal qwerty keyboard, so if you just want to enter a number, because it's quicker, i would advice a integer variable)
 

Attachments

  • example.png
    example.png
    122.9 KB · Views: 31

Dm114

Well-known member
But both requires you to create a separate macro for each action? This can become messy and hard to manage...
The first solution (with the use of a 'User prompt' for a boolean variable→2 options) doesn't require additional macro. You just have to test the true/false value (according to the button pressed by the user).

For example, if you associate the text 'Spotify' to the True value, you'll launch Spotify, otherwise (False value), you'll launch the native app.

The solution proposed by 420 is a bit less convenient for the user to reply. He has to enter a number and then press 'OK' instead of a simple click. But it's the only way (I often use) when you have more than 2 or 3 options...
 
  • Like
Reactions: 420

chaoscreater

Active member
Thanks, I get it now.

For the method using integers (set variable user prompt), is it possible to change the default value from 0 to something else? And is it possible to associate the numbers with a text or description? If I have 10 choices, I don't necessarily remember what 0~9 are.
 

Dm114

Well-known member
Thanks, I get it now.

For the method using integers (set variable user prompt), is it possible to change the default value from 0 to something else? And is it possible to associate the numbers with a text or description? If I have 10 choices, I don't necessarily remember what 0~9 are.
Here is an example with an integer variable.

As you can see you have many possibilities:
- Boolean variable*
- Integer variable* (you even can add emojis in your text such as 0️⃣ to 🔟 if your Android version has these symbols)
- Macro run

Now it's up to you: make your choice. 😉

* to initiate a value, add a 'Set variable' action with the initial value before displaying 'User prompt'
 

Attachments

  • Screenshot_20210510-092704_MacroDroid.jpg
    Screenshot_20210510-092704_MacroDroid.jpg
    317.8 KB · Views: 25

chaoscreater

Active member
I would use Macro Run [User prompt].
Yeah, but that would require you to create multiple macros and multiple categories. Macro Run requires you to specify a category to load the macros from. If you want to present a list of options during the user prompt, you would need to create individual macros for each of the options and put them all in just their own category. Otherwise, if you have a category of 100 macros, they will all be presented during the user prompt.


Anyway, I'm now facing a new issue when using set variable boolean or set variable integer. Let's say I'm using set variable boolean and I cancel the user prompt. It should just do nothing at that point, but instead it goes and executes the "if variable = false" condition, which I do not want. The same is true for the set variable integer. If I cancel the user prompt, it still executes the condition and I have made sure I have my if and if-else loop closed correctly.

I also tried playing around with the user prompt setting "Cancel prevents subsequent actions running". Problem with this is that it cancels literally every action below it. I still want to execute other actions.


If I use if-confirmed, then cancelling the prompt will cancel the action as expected. Problem is that if-confirmed is limited to the number of options presented in the user prompt....


UPDATE:

Ahh, I know what the issue is........when you create a variable, it will be created with a default value (e.g. false for a boolean variable). Even though you've cancelled the action, the value of "false" is still there and so the "if variable = false" condition gets executed.

This means that I would need to use the set variable integer and have a default value of 0 that doesn't do anything. Then create an "if int = 1" and "if else int = 2", etc. But I would much rather just tap on an option instead of having to delete and add an integer value during the prompt.....also, this means I can't set a default value (e.g. int = 1) before the user prompt. If I were to cancel the prompt, it would just use the default value of 1 and execute the if loop.

I've got it working currently using set variable integer. But I can't set a default value to something I want. I need to keep it at 0 (which doesn't do anything as I do not have a condition for when the int = 0).

Ideally, something that is like if-confirmed but with multiple user options is what I'm really after. If-confirmed doens't use variables, it only prompts you with one question and you get an OK or Cancel button. I just need this to be extended to have multiple user prompt options. I think using checkboxes for each user prompt option would achieve this.
 
Last edited:

Dm114

Well-known member
Yeah, but that would require you to create multiple macros and multiple categories. Macro Run requires you to specify a category to load the macros from. If you want to present a list of options during the user prompt, you would need to create individual macros for each of the options and put them all in just their own category. Otherwise, if you have a category of 100 macros, they will all be presented during the user prompt.


Anyway, I'm now facing a new issue when using set variable boolean or set variable integer. Let's say I'm using set variable boolean and I cancel the user prompt. It should just do nothing at that point, but instead it goes and executes the "if variable = false" condition, which I do not want. The same is true for the set variable integer. If I cancel the user prompt, it still executes the condition and I have made sure I have my if and if-else loop closed correctly.

I also tried playing around with the user prompt setting "Cancel prevents subsequent actions running". Problem with this is that it cancels literally every action below it. I still want to execute other actions.


If I use if-confirmed, then cancelling the prompt will cancel the action as expected. Problem is that if-confirmed is limited to the number of options presented in the user prompt....


UPDATE:

Ahh, I know what the issue is........when you create a variable, it will be created with a default value (e.g. false for a boolean variable). Even though you've cancelled the action, the value of "false" is still there and so the "if variable = false" condition gets executed.

This means that I would need to use the set variable integer and have a default value of 0 that doesn't do anything. Then create an "if int = 1" and "if else int = 2", etc. But I would much rather just tap on an option instead of having to delete and add an integer value during the prompt.....also, this means I can't set a default value (e.g. int = 1) before the user prompt. If I were to cancel the prompt, it would just use the default value of 1 and execute the if loop.

I've got it working currently using set variable integer. But I can't set a default value to something I want. I need to keep it at 0 (which doesn't do anything as I do not have a condition for when the int = 0).

Ideally, something that is like if-confirmed but with multiple user options is what I'm really after. If-confirmed doens't use variables, it only prompts you with one question and you get an OK or Cancel button. I just need this to be extended to have multiple user prompt options. I think using checkboxes for each user prompt option would achieve this.
If you have to execute some actions even if you do not select a 'valid' option in the menu, why wouldn't you create an option called 'do nothing' or 'none of these' (corresponding to the value zero)?

For the rest of your request, yes, depending on the complexity of your/our needs, it's sometimes necessary to use some lines of code. But it's fun!
MacroDroid is a kind of 'Tool box' where you can find nearly all the possible tools to do whatever you want (inside Android/Google limits, which become narrower every month ☹️) in a very intuitive manner unlike a programming language. Unlike a dedicate app, MD is very versatile and sometimes we have to create our 'homemade functions' to exactly fit our own needs...

Good luck and have fun!
 

chaoscreater

Active member
If you have to execute some actions even if you do not select a 'valid' option in the menu, why wouldn't you create an option called 'do nothing' or 'none of these' (corresponding to the value zero)?

For the rest of your request, yes, depending on the complexity of your/our needs, it's sometimes necessary to use some lines of code. But it's fun!
MacroDroid is a kind of 'Tool box' where you can find nearly all the possible tools to do whatever you want (inside Android/Google limits, which become narrower every month ☹️) in a very intuitive manner unlike a programming language. Unlike a dedicate app, MD is very versatile and sometimes we have to create our 'homemade functions' to exactly fit our own needs...

Good luck and have fun!

Sorry for the late reply, I missed your message and only just remembered that I posted this question.

As per my previous reply, when you create a "integer: [User Prompt]" variable, the default value is 0 and you cannot modify this (as far as I know). You can't simultaenously use 0 for a default option and also to cancel the prompt at the same time.

Take the following for example:

Set variable:
User_Choice: [User Prompt]

User prompt shows:
1 - Option A
2 - Option B

if (User_Choice = 1){

do something...
}

if (User_Choice = 2){

do something...
}

When the prompt pops up, the input box has a default value of 0. Assuming you don't modify this value, then when you press OK, it should do nothing - because there is no "if (User_Choice = 0)" condition. The same is true when you press Cancel, the popup should go away and nothing happens. That's fine, that's what we want.

Now, let's say you want to make use of the default value of 0.

Set variable:
User_Choice: [User Prompt]

User prompt shows:
1 - Option A
2 - Option B

if (User_Choice = 0){

do something...
}

if (User_Choice = 1){

do something...
}

if (User_Choice = 2){

do something...
}

Again, when the user prompt pops up, the value 0 is there by default. When you press OK, it starts executing the code under "if (User_Choice = 0)". That's great.

BUT, what happens when you want to CANCEL the prompt? Well, the code under "if (User_Choice = 0" gets executed anyway. Why? Because like I said, the "Cancel" action in the user prompt doesn't actually cancel properly. Since the "integer: [User Prompt]" always has a default value of 0, then the condition "if (User_Choice = 0)" will always get executed. So the "Cancel" action is bugged here and needs to be fixed.

Currently, I don't have a condition for "if (User_Choice = 0)" and so when I click Cancel on the prompt, it does nothing. However, like I said above, you lose the ability to make use of the default value of 0 properly. So what also needs to be addressed here is the ability to modify the default integer value for the "integer: [User Prompt]" variable.

Now, even if both those issues were fixed, it's still a pretty crappy user experience. I don't want to have to type backspace to delete the number (again, 0 is the default) and then type in the number I want. It is slow and an inefficient process. It is MUCH BETTER to simply tap an option/choice button, like the one you get from the "if confirmed" option. Like I said, "if confirmed" needs to be enhanced/extended so that it provides multiple options for you to select. Currently, it only presents the option of "Confirmed" and "Cancelled".
 

420

Active member
Sorry for the late reply, I missed your message and only just remembered that I posted this question.

As per my previous reply, when you create a "integer: [User Prompt]" variable, the default value is 0 and you cannot modify this (as far as I know). You can't simultaenously use 0 for a default option and also to cancel the prompt at the same time.

Take the following for example:



When the prompt pops up, the input box has a default value of 0. Assuming you don't modify this value, then when you press OK, it should do nothing - because there is no "if (User_Choice = 0)" condition. The same is true when you press Cancel, the popup should go away and nothing happens. That's fine, that's what we want.

Now, let's say you want to make use of the default value of 0.



Again, when the user prompt pops up, the value 0 is there by default. When you press OK, it starts executing the code under "if (User_Choice = 0)". That's great.

BUT, what happens when you want to CANCEL the prompt? Well, the code under "if (User_Choice = 0" gets executed anyway. Why? Because like I said, the "Cancel" action in the user prompt doesn't actually cancel properly. Since the "integer: [User Prompt]" always has a default value of 0, then the condition "if (User_Choice = 0)" will always get executed. So the "Cancel" action is bugged here and needs to be fixed.

Currently, I don't have a condition for "if (User_Choice = 0)" and so when I click Cancel on the prompt, it does nothing. However, like I said above, you lose the ability to make use of the default value of 0 properly. So what also needs to be addressed here is the ability to modify the default integer value for the "integer: [User Prompt]" variable.

Now, even if both those issues were fixed, it's still a pretty crappy user experience. I don't want to have to type backspace to delete the number (again, 0 is the default) and then type in the number I want. It is slow and an inefficient process. It is MUCH BETTER to simply tap an option/choice button, like the one you get from the "if confirmed" option. Like I said, "if confirmed" needs to be enhanced/extended so that it provides multiple options for you to select. Currently, it only presents the option of "Confirmed" and "Cancelled".
i do agree that the "display dialog" and "option dialog" actions could be improved, we can now use "UItask" plugin, but these pop-ups take longer to load and it doesn't regocnize the new line symbol, it would be very nice to have the same option in macrodroid, (a "button" variable that changes to which button is pressed) but untill that happens we have to make do with what we have.

as for setting a different default then 0, you could do this by simply adding a set variable action above the set variable [user input] action.

as for the cancel not working properly, for me it works fine with the "cancel prevents subsequent actions running" box ticked on the set variable [user input] action.

as for your last issue, aslong as 0 is the default you do NOT have to remove the 0! you can just type whatever number behind it and press ok, the 0 will automatically be removed.
 
Last edited:

chaoscreater

Active member
as for setting a different default then 0, you could do this by simply adding a set variable action above the set variable [user input] action.

as for the cancel not working properly, for me it works fine with the "cancel prevents subsequent actions running" box ticked on the set variable [user input] action.

as for your last issue, aslong as 0 is the default you do NOT have to remove the 0! you can just type whatever number behind it and press ok, the 0 will automatically be removed.

Yes, "cancel prevents subsequent actions running" will do the job, the problem is that enabling this isn't always desired. There are cases where you have nested conditions and you still want the rest of the actions in the macro to continue. Some of the actions are not part of any if-else conditions and they will break when you have the "cancel prevents subsequent actions running" enabled. When you're building a complex macro that depends on a lot of user choices from the prompts, then these features have to be bug-free and work well enough to properly empower the users...

What's also interesting is that if you completely ignore the "cancel prevents subsequent actions running", then the cancel button itself doesn't actually do anything, so what's the point of it?

Therefore, the ONLY way to properly cancel just the current prompt and NOT the rest of the prompts or actions, is to set the default value of 0 to do nothing and not enable "cancel prevents subsequent actions running".

As for typing any number to replace 0, I didn't know about that. This saves me an extra step. However, it's still annoying to have to pick the right number to type, based on the choice you want. I often rotate my phone to landscape mode while I'm driving. The apps I use are in landscape mode, but sometimes Macrodroid doesn't rotate the user prompt to landscape and so I have to tilt my head to the side to pick the correct number. It is still much easier to tap just one on a button, than having to pick the number, type it in, press OK and then repeat this depending on how many user prompts you have. The more user prompts you have, the more wasted actions there are.

I mean, the if-confirmed prompt is already there. I don't think it should be that hard to make it show a couple more buttons as choices for you to pick?
 

420

Active member
I have a macro that uses multiple if-confirmed clauses and so I'll get multiple pop-up boxes asking for different questions. For example, the popup box will ask me if I want to open Spotify and if yes, it will launch Spotify. If I choose no, it will ask me if I want to open the native Music app instead. Another example is that I will get asked if I want to open Google Maps, if not then it will ask if I want to open Waze and if not, it'll ask if I want to open Here Maps, etc.

It would be so much easier if I could get a single diaglog box with multiple options. I can check the ones I want in a tickbox and then it will store the answers into a variable and then I can create my actions using the variables.
maybe you can use the "list dialog" action from UItask plugin.. it's a bit tricky to set up but it let's you pick from a list, you can also set it up so you can select multiple options at once.
 

Attachments

  • Screenshot_20210706-143544.png
    Screenshot_20210706-143544.png
    113.3 KB · Views: 15
  • Screenshot_20210706-144325.png
    Screenshot_20210706-144325.png
    118.6 KB · Views: 15
Top