User Tools

Site Tools


action:Switch_or_Case

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
Last revision Both sides next revision
action:Switch_or_Case [2016/11/27 18:15]
JMichaelTX ADD example screenshot, icon, rewrite description
action:Switch_or_Case [2021/10/15 01:32]
peternlewis [Conditions]
Line 1: Line 1:
-{{:​action:​switch-icon.png?​nolink|}} +====== Switch/Case Action ======
-====== Switch ​or Case Action ======+
  
-**The //​Switch ​or Case action// is used to perform different actions based on different values of a common _parameter_.**  It is very similar to the [[https://​developer.mozilla.org/​en-US/​docs/​Web/​JavaScript/​Reference/​Statements/​switch|JavaScript Switch]] statement.+The //Switch/Case action// is used to perform different actions based on different values of a common _parameter_. ​ It is very similar to the [[https://​developer.mozilla.org/​en-US/​docs/​Web/​JavaScript/​Reference/​Statements/​switch|JavaScript Switch]] statement.
  
 The _Switch_ Action is a good alternative to using multiple, nested, [[action:​If_Then_Else|If/​Then]] Actions. The _Switch_ Action is a good alternative to using multiple, nested, [[action:​If_Then_Else|If/​Then]] Actions.
- 
----- 
  
 ===== Parameters ===== ===== Parameters =====
  
-**The Switch _parameter_ may be any of the following:**+The Switch _parameter_ may be any of the following:
   * [[:​Clipboards|System Clipboard]]   * [[:​Clipboards|System Clipboard]]
   * [[:​Clipboards#​Named_Clipboards|Named Clipboard]]   * [[:​Clipboards#​Named_Clipboards|Named Clipboard]]
-  * [[:​Variables|Keyboard Maestro Variable]]+  * [[token:​TriggerClipboard|Trigger Clipboard]] 
 +  * [[manual:​Variables|Keyboard Maestro Variable]]
   * Text (which can use [[:​Tokens|Tokens]])   * Text (which can use [[:​Tokens|Tokens]])
- +  * [[manual:​Calculations|Calculation]] 
----- +  * File
  
 ===== Default Configuration ===== ===== Default Configuration =====
Line 23: Line 20:
 When you insert the _Switch_ Action, it is configured to switch based on the _System Clipboard_, but can be easily changed to other parameters. ​ It initially looks like this: When you insert the _Switch_ Action, it is configured to switch based on the _System Clipboard_, but can be easily changed to other parameters. ​ It initially looks like this:
  
-{{:action:km-7.3-switch.png?​nolink|}}+{{:action:switch-case.png?​nolink|}}
  
 For each _Condition_ that you add, you can enter zero or more _Actions_ that will be executed when that _Condition_ is met.  After those _Action(s)_ are executed, or if no _Conditions_ are met, the _Switch_ Action is exited. For each _Condition_ that you add, you can enter zero or more _Actions_ that will be executed when that _Condition_ is met.  After those _Action(s)_ are executed, or if no _Conditions_ are met, the _Switch_ Action is exited.
- 
----- 
- 
  
 ===== Conditions ===== ===== Conditions =====
  
 +The _Conditions_ available depend on the _Parameter_ that is chosen (for example, you cannot use *has an image* with a calculation).
  
-The _Condition_ can be and of the following:+The _Conditions_ are defined as follows:
  
-has text of some sort. +^Condition^Definition^ 
-does not have text. +|is empty|The text is contains no characters.| 
-has an image of some sort+|is not empty|The text is contains some characters.| 
-does not have an image. +|has text |Clipboard ​has at least one item containing ​text of some sort.| 
-is exactly (case insensitivelyspecified string. +|does not have text |Clipboard does not have any text items.| 
-is not exactly (case insensitivelyspecified string. +|has image |Clipboard has one or more images.| 
-is alphabetically before ​specified string. (v7.2+) +|does not have image |Clipboard does not have any images.| 
-is alphabetically after specified string. (v7.2+) +|is |is exactly (case insensitivethe specified string.| 
-* contains (case insensitively) a specified string. +|is not |is not exactly (case insensitivethe specified string.| 
-* does not contain (case insensitively) a specified string. +|contains |contains (case insensitive) the specified string.| 
-matches ​specified regular expression. +|does not contain |does not contain (case insensitive) the specified string.| 
-does not match specified regular expression. +|starts with |starts with the specified string.| 
-has some flavor ​that conforms to the specified [Uniform Type Identifier](https://​en.wikipedia.org/​wiki/​Uniform_Type_Identifier). +|ends with |ends with the specified string.| 
-does not have a flavor ​that conforms to the specified Uniform Type Identifier. +|is before |is alphabetically before ​the specified string. (v7.2+)| 
-otherwise ​(aka always).+|is after |is alphabetically after the specified string. (v7.2+)| 
 +|matches ​|matches the specified regular expression.| 
 +|does not match |does not match the specified regular expression.| 
 +|is <|is numerically less than.| 
 +|is <=|is numerically less than or equal.| 
 +|is =|is numerically equal.| 
 +|is >=|is numerically greater than or equal.| 
 +|is >|is numerically greater than.| 
 +|is !=|is numerically not equal.| 
 +|conforms to |Clipboard ​has an item with the UTI class that conforms to the specified [Uniform Type Identifier](https://​en.wikipedia.org/​wiki/​Uniform_Type_Identifier).| 
 +|does not conform to |Clipboard ​does not have an item with the UTI class that conforms to the specified Uniform Type Identifier.| 
 +|otherwise ​|will execute if none of the Conditions in the Switch, that are entered above _otherwise_,​ are met.|
  
-The _Otherwise_ _Condition_ will execute if none of the above _Conditions_ are met.  The _Switch_ Action will then exit.  So, the _Otherwise_ _Condition_ should always be placed as the last _Condition_ in the _Switch_ Action. 
- 
----- 
  
 +The _Otherwise_ _Condition_ will execute if none of the previous _Conditions_ are met.  The _Switch_ Action will then exit.  So, the _Otherwise_ _Condition_ should always be placed as the last _Condition_ in the _Switch_ Action.
  
 ===== See Also ===== ===== See Also =====
- 
----- 
  
 === Actions === === Actions ===
  
 * [[action:If Then Else|If Then Else]] * [[action:If Then Else|If Then Else]]
-* [[action:Pause|Pause Until Conditions Met]]+* [[action:Pause_Until|Pause Until Conditions Met]]
 * [[action:​Until|Execute Action Until Conditions Met]] * [[action:​Until|Execute Action Until Conditions Met]]
 * [[action:​While|Execute Action While Conditions Met]] * [[action:​While|Execute Action While Conditions Met]]
Line 71: Line 73:
  
 * [[:​Conditions|See all Conditions]] * [[:​Conditions|See all Conditions]]
- 
----- 
  
 ==== Forum ==== ==== Forum ====
  
-- [[https://www.google.fr/search?​q=site:​forum.keyboardmaestro.com+Switch+action|Keyboard Maestro Forum topics about Switch or Case action]] +- [[https://forum.keyboardmaestro.com/t/​action-switch-case-based-on-frontmost-app/​7294|ACTIONSwitch Case Based on FrontMost App]] 
 +- [[https://forum.keyboardmaestro.com/search?q=Switch%20action|Keyboard Maestro Forum topics about Switch or Case action]]
  
action/Switch_or_Case.txt · Last modified: 2022/09/17 22:49 by peternlewis