User Tools

Site Tools


action:Prompt_for_User_Input

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
action:Prompt_for_User_Input [2021/10/14 02:57]
peternlewis
action:Prompt_for_User_Input [2023/09/13 00:04] (current)
peternlewis [Slider Field]
Line 59: Line 59:
  
 The field will be displayed as a single line text input field. The field will be displayed as a single line text input field.
 +
 +The default field is a token text field.
  
 ==== Password Field ==== ==== Password Field ====
  
 The field will be displayed as a single line password input field, displayed with bullets instead of characters. The field will be displayed as a single line password input field, displayed with bullets instead of characters.
 +
 +The default field is a token text field.
  
 ==== Checkbox ==== ==== Checkbox ====
  
 The field will be displayed as a checkbox. If the default value is “0”, or starts with “0|”, then the checkbox will default to off. If the default value is “1”, or starts with “1|”, the checkbox will default to on. The field will be displayed as a checkbox. If the default value is “0”, or starts with “0|”, then the checkbox will default to off. If the default value is “1”, or starts with “1|”, the checkbox will default to on.
 +
 +The default field is a token text field.
  
 ==== Menu Field ==== ==== Menu Field ====
Line 96: Line 102:
  
 The result stored in the variable will be the value of the slider. The result stored in the variable will be the value of the slider.
 +
 +This default value field is a calculation field.
 +
 +Up to Keyboard Maestro version 10.2, the result of the slider will always be an integer, and any initial value above 100 will be clipped to 100 ([[https://​forum.keyboardmaestro.com/​t/​slider-keeps-rounding-my-values-down/​32936|forum]]). Neither of these limitations apply in version 11.0+.
  
 ==== Color Field ==== ==== Color Field ====
Line 102: Line 112:
  
 The default ​ value defines the color with three or four comma-separated values, being the red, green, blue and optional alpha values. All values have a range of 0 to 255. The default ​ value defines the color with three or four comma-separated values, being the red, green, blue and optional alpha values. All values have a range of 0 to 255.
 +
 +This default value field is a calculation field.
  
 ==== Date and Time Fields ==== ==== Date and Time Fields ====
Line 109: Line 121:
 The default value is [[/​unixtime|unixtime]] for the date and time. For time-only values, you can use either a unixtime or a time in seconds in the day (so 28,800 would be 8am) - either way the result will be in the same day as the specified default value. The default value is [[/​unixtime|unixtime]] for the date and time. For time-only values, you can use either a unixtime or a time in seconds in the day (so 28,800 would be 8am) - either way the result will be in the same day as the specified default value.
  
 +This default value field is a calculation field.
  
 +==== Labels ====
  
 +It can be a good idea to have a common prefix in all of the variables used by the same macro. ​ This clearly identifies the macro that uses these variables, and groups them together in the Variables section of the Keyboard Maestro Preferences. ​ But you may not want to expose this prefix to the user running the macro.
  
 +So, you can hide the prefix if the variable name starts with a prefix followed by two underscores. Then the label will show only the latter part of the variable name.
  
 +Similarly, you can use Instance or Local variables, and the “Instance” or “Local” will be removed from the variable name when displayed in the form.
  
- +For example, ​variables named MyMacro‗‗Text Message”, “Instance Text Message” or “Local Text Message” ​will all display ​the label Text Message” in the form. The actual variable ​used will be the full variable name.
- +
- +
- +
-=== How to Use a Variable for the Popup Choices === +
- +
-* Sometimes you might like to use a Keyboard Maestro Variable to store the list of Popup Choices, and then use this Variable in the Prompt for User Input Action. ​ This can be done simply starting the default value for the Popup with a vertical bar (`|`). +
-* If the Popup default value starts with a bar (|), then the Variable (which contains choices separated by `|`) will be expanded and evaluated before the Prompt is displayed, thus showing the choices from the Variable.  +
- +
-Otherwise, the entry is separated by bar first, and then token expansion is applied to each field, so that fields may contain bars, for example, “This|That|%Variable%One Entry%+
- +
-=== How to Hide a Variable Prefix in the Prompt === +
- +
-It is a good idea to have a common prefix in all of the variables used by the same macro. ​ This clearly identifies the macro that uses these variablesand groups them together in the Variables section of the Keyboard Maestro Preferences. ​ But you may not want to expose this prefix to the user running the macro. +
- +
-**So, you can hide the prefix if the variable name starts with a prefix followed by two underscores**. Then the label will show only the latter part of the variable name. +
- +
-For example, if you enter "​**`MyMacro__Text ​Message`**" in the variable name field of the Prompt for User Input action: +
-  * It will display ​label of "**`Text Message`**":​ +
-  * But the actual variable ​name that is set will be just as you entered it: "​**`MyMacro__Text Message`**"​ +
- +
-==== Checkbox Field ==== +
- +
-If the popup menu would contain only "​0"​ and "​1",​ then a checkbox is used (so for example, “0|1"​ or "​1|0",​ depending on the desired default).+
  
 ==== Buttons ==== ==== Buttons ====
Line 144: Line 138:
   - {{:​action:​km-7.3-ok-button.png?​nolink|}}   - {{:​action:​km-7.3-ok-button.png?​nolink|}}
     * Responds to shortcut <​kbd>​⏎</​kbd>​ (RETURN)     * Responds to shortcut <​kbd>​⏎</​kbd>​ (RETURN)
-    * Closes the Prompt +    * Closes the Prompt. 
-    * Flows proceeds to next Action+    * Flows proceeds to next Action.
   - {{:​action:​km-7.3-cancel-button.png?​nolink|}}   - {{:​action:​km-7.3-cancel-button.png?​nolink|}}
     * Responds to shortcuts of either <​key>​⎋</​key>​ (ESCAPE), or <​key>​⌘</​key><​key>​.</​key>​ (COMMAND-PERIOD)     * Responds to shortcuts of either <​key>​⎋</​key>​ (ESCAPE), or <​key>​⌘</​key><​key>​.</​key>​ (COMMAND-PERIOD)
-    * Closes the Prompt+    * Closes the Prompt ​**without writing the variables**.
     * **Cancels the Macro**     * **Cancels the Macro**
  
-=== Optional Buttons Can be Assigned Shortcut Keys ===+You can add more buttons to allow for other options. For example, “Save” and “Save and Send”.
  
-You can optionally assign a shortcut key by applying a suffix to the Button Name in the form of /​«character»,​ which will cause the Button to respond to a keystroke of <​key>​⌘</​key><​key>/​«character»</​key>​+You can optionally assign a shortcut key by applying a suffix to the Button Name in the form of /​«character»,​ which will cause the Button to respond to a keystroke of <​key>​⌘</​key><​key>​«character»<​/key> (or just <key>«character»</​key> ​if there are no focusable text fields).
  
 ^Suffix^Button Responds to Shortcut Key of:^ ^Suffix^Button Responds to Shortcut Key of:^
 |`/​.`|<​key>​⎋</​key>​ (ESCAPE) key.| |`/​.`|<​key>​⎋</​key>​ (ESCAPE) key.|
 |`/​`|<​kbd>​⏎</​kbd>​ (RETURN) key.| |`/​`|<​kbd>​⏎</​kbd>​ (RETURN) key.|
-|`/​H`|<​key>​⌘</​key><​key>​H</​key>​ keystroke (as an example).\\ (The <key></​key> ​key is not needed IF there are not any text fields in the Prompt User dialog)|+|`/​H`|<​key>​⌘</​key><​key>​H</​key>​ keystroke (as an example) (or just <key>H</​key> ​if there are not any text fields in the form)
 +|`/-`|no shortcut|
  
 === Result Button === === Result Button ===
Line 166: Line 161:
 === How Buttons are Processed === === How Buttons are Processed ===
  
-* The first button (from the top) has a default key of <​kbd>​⏎</​kbd>​ (RETURN), _unless_ you have assigned the _RETURN_ response to another button using “/” at the end of a button name.+* The first button (from the top) has a default key of <​kbd>​⏎</​kbd>​ (RETURN), _unless_ you have assigned the _RETURN_ response to another button using “/” at the end of a button name, or marked the button to cancel the macro.
 * The second button has a default key of either <​key>​⎋</​key>​ (ESCAPE), or <​key>​⌘</​key><​key>​.</​key>​ (COMMAND-PERIOD),​ _unless_ you have turned off canceling the macro for that button or assigned the _ESCAPE_ response to another button using “/.” at the end of a button name. * The second button has a default key of either <​key>​⎋</​key>​ (ESCAPE), or <​key>​⌘</​key><​key>​.</​key>​ (COMMAND-PERIOD),​ _unless_ you have turned off canceling the macro for that button or assigned the _ESCAPE_ response to another button using “/.” at the end of a button name.
 * Any button can _Cancel_ the macro if the "​Cancel Macro" checkbox is _checked_ for it. * Any button can _Cancel_ the macro if the "​Cancel Macro" checkbox is _checked_ for it.
Line 173: Line 168:
 * If you have the system preference “Use keyboard navigation to move focus between controls” enabled, the button shown with a colored outline (usually blue) can be chosen/​activated by pressing the _SPACE_ key. * If you have the system preference “Use keyboard navigation to move focus between controls” enabled, the button shown with a colored outline (usually blue) can be chosen/​activated by pressing the _SPACE_ key.
  
-**Guidelines for Good Button ​UI**+=== Guidelines for Good Button ​User Experience ===
  
-* The default button should be the "OK" ​button, the one that performs the *normal behaviour*.+* The default button should be the OK” button, the one that performs the *normal behaviour*.
 * The default button should be rightmost. * The default button should be rightmost.
 * The left most button should be "​Cancel"​. * The left most button should be "​Cancel"​.
Line 181: Line 176:
 * If the normal behaviour is significantly dangerous, then it may be appropriate for it to not be the default button, or for there to be no default button. * If the normal behaviour is significantly dangerous, then it may be appropriate for it to not be the default button, or for there to be no default button.
  
-"​normal ​behaviour" ​here is defined as doing what the user just asked to do.+“Normal ​behaviour” here is defined as doing what the user just asked to do.
  
 A consequence of all of this is that if you have a second button in the Prompt For User Input action, and it does not cancel the macro, then you should definitely give it some other key, or disable it with “/-”. A consequence of all of this is that if you have a second button in the Prompt For User Input action, and it does not cancel the macro, then you should definitely give it some other key, or disable it with “/-”.
- 
-An update is planned so that if the first button has the Cancel Macro flag, then it is not the default (by default), and if the second button does not have the Cancel Macro flag, then it does not get the Escape/​Command-,​ key (by default). 
  
 ===== Notes ===== ===== Notes =====
  
 Note that the system will not allow Keyboard Maestro Engine to see keys typed in its own windows so the [[trigger:​Typed String]] triggers will not work within Keyboard Maestro Engine windows. Note that the system will not allow Keyboard Maestro Engine to see keys typed in its own windows so the [[trigger:​Typed String]] triggers will not work within Keyboard Maestro Engine windows.
- 
-Note that the system really really wants a "​default"​ button, and if you do not give it one, it will choose one for you. 
  
 ===== See Also ===== ===== See Also =====
action/Prompt_for_User_Input.1634194649.txt.gz · Last modified: 2021/10/14 02:57 by peternlewis