Curious if there is a way to have the user prompt display with a checkbox that gets it’s on / off status from a variable? That is, if variable “Full” is 1, then the prompt would display a checkbox already checked with the variable name to the right of the checkbox.
Great help, thanks Tom. Looking at it now it makes perfect sense that this is how it would work. Now that I can do this I wrote a quick AppleScript to convert variables with a 1 into 1|0 and variables with a 0 into 0|1 and then ran the input prompt as intended.
You don’t need to do that, you can var %Variable%MyVar%|0|1
Keyboard Maestro uses the first entry as the default/selected entry (hence uses the 0 or 1 from the variable to set the initial value), and is smart enough to see that even though there are three values, they are all 0 or 1, so it is still a checkbox.
Hello @Tom, thank you very much for the posted macro Since I'm not a KM nerd, I have a question about the "set variable..."
You use here for the first 0|1 and the second 1|0. If I continue this with 2|0 and 3|0, these are selected directly when calling.
However, if I mark them all with 0|1, then I can call up and activate/deactivate them all.
1|0 simply means ‘checkbox selected’, 0|1 means ‘checkbox not selected’. (By default.)
I don’t know what 2|0 and 3|0 should do. The KM Wiki article doesn’t mention it. But maybe I’m missing something or this is something new. (If this is not something new then I guess that 2|0 or 3|0 works just like 1|0)
Not sure if I understand. Also when they are set to 1|0 you should be able to select/deselect the checkboxes. The 1|0 or 0|1 just sets the state of the checkbox when the prompt comes up. Once you actually select/deselect a checkbox the new value (0 or 1) is used.
Thank you for your quick answer. It was my mistake of thought that I meant...
1|0 = Icons
2|0 = Desktop
3|0 = Night Shift
etc.
would have something to do with the number/arrangement (numbering) of the checkboxes and would not be marked or unchecked. Just as the variables are numbered consecutively.
For me it was/is important that the input window opens and no checkbox is checked. I did, yes, I did, even though unconsciously. Thank you very much again.
By choosing the format n|n (where n is either ‘0’ or ‘1’) you are telling the prompt that the input field should be a Checkbox Input Field (and not a text input field etc.).
Then, by either putting 1 or 0 on the first position you tell the prompt what the default state of that Checkbox should be (0|1: off; 1|0: on).
Yep, don’t hesitate to ask in the forum. Plenty of helpful people here. Also the KM Wiki (which has improved significantly over the last years) provides a lot of useful information. I’m also looking up things on the Wiki frequently.
I think this is mainly thanks to the work of @JMichaelTX, @peternlewis, @ccstone. And, of course, many of the improvements to the Wiki originate from (or are inspired by) questions and contributions by many forum members.
Ehm, sorry, just read your post again (sometimes I’m a bit slow). What you probably wanted to do —I think— is constructing a popup button (not a check box). Like this:
You can also differentiate between the displayed value and the “real” value by prepending the real value to the displayed value, separated by 2 underscores:
Thank you for the information on the pop-up button
I expressed myself wrongly from my side. I assumed that I would have to continue the enumeration for further checkboxes, as shown on the ScreenShot...
Now I know that this is underexposed for the function of the checkboxes. Thanks to your help, I'm now aware of the behavior of 0|1 and 1|0.
Can I use your macro for a YouTube tutorial? Of course I would link your contribution as a source in my tutorial.