Variables
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| Variables [2017/08/02 07:00] – [Using Variables in Scripts] peternlewis | Variables [2017/09/26 05:17] (current) – removed peternlewis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Keyboard Maestro Variables ====== | ||
| - | Keyboard Maestro variables are used much like variables in any scripting or macro language. | ||
| - | |||
| - | ===== Key Facts about Variables ===== | ||
| - | |||
| - | **Keyboard Maestro Variables have some aspects that are quite different from traditional programming languages: | ||
| - | |||
| - | * Each Macro may create Variables and read existing Variables. | ||
| - | * **All Variables persist, permanently stored on your Mac (much like a file) until deleted**. | ||
| - | * All Variables are global, fully accessible (create, read, write, delete) by: | ||
| - | * All other Macros | ||
| - | * Future executions of the same macro | ||
| - | * Scripts | ||
| - | * AppleScript | ||
| - | * //Keyboard Maestro Editor Preferences// | ||
| - | * :!: **Note: | ||
| - | * **All Keyboard Maestro variables can contain only plain text**. | ||
| - | * However, you can use variables that contain numbers in calculations in [[https:// | ||
| - | |||
| - | |||
| - | ===== Setting Variables ===== | ||
| - | |||
| - | Variables are usually created and set by [[: | ||
| - | |||
| - | |||
| - | The most common Action to set a variable is, well, [[action: | ||
| - | |||
| - | {{ : | ||
| - | |||
| - | There are a number of other [[: | ||
| - | * [[action: | ||
| - | * [[action: | ||
| - | * [[action: | ||
| - | * [[action: | ||
| - | |||
| - | In addition to these, there are a number of more complex Actions that can also set a variable. | ||
| - | |||
| - | When setting a variable, you will be using a text field in most cases. :!: Be aware that [[: | ||
| - | |||
| - | ===== Using Variables ===== | ||
| - | |||
| - | There are many Macro Actions that can use variables. | ||
| - | |||
| - | ==== Variable Tokens ==== | ||
| - | |||
| - | The // | ||
| - | where `< | ||
| - | |||
| - | For Example, using the [[action: | ||
| - | |||
| - | {{ : | ||
| - | |||
| - | You can (v7.2+) access a variable as if it is a comma separated array of text using the notation // | ||
| - | |||
| - | You can also use a short form of just //%Variable Name%// to include variables as long as the variable exists and has a value and there is no corresponding text token, although generally it is better and clearer to use the longer form // | ||
| - | |||
| - | |||
| - | ==== Variable Arrays ==== | ||
| - | |||
| - | Variables can contain an array of comma separated **numbers**, | ||
| - | |||
| - | **It is important to note that variable arrays can contain only numeric values**. | ||
| - | |||
| - | For example, suppose the variable `MyArray` has this value: `10, | ||
| - | |||
| - | ===== Using Variables in Scripts ===== | ||
| - | |||
| - | You can get and set Keyboard Maestro Variables in these types of scripts: | ||
| - | * [[: | ||
| - | * [[: | ||
| - | * [[action: | ||
| - | * (Browser JavaScript can only GET Keyboard Maestro Variables. | ||
| - | * [[action: | ||
| - | * [[action: | ||
| - | * [[action: | ||
| - | |||
| - | And you can generally access Keyboard Maestro variables anywhere else via [[: | ||
| - | |||
| - | Click on the above links for example scripts. | ||
| - | |||
| - | ===== Password Variables ===== | ||
| - | |||
| - | Variables with names that start or end with “Password” or “PW” are considered passwords – their values will not be stored (except in memory) and they cannot be read directly by shell scripts or AppleScripts, | ||
| - | |||
| - | ===== See Also ===== | ||
| - | |||
| - | ---- | ||
| - | |||
| - | === Actions === | ||
| - | |||
| - | * [[action: | ||
| - | * [[action: | ||
| - | * [[: | ||
| - | |||
| - | ---- | ||
| - | |||
| - | ==== Forum ==== | ||
| - | |||
| - | - [[https:// | ||
| - | - [[https:// | ||
| - | |||
| - | - [[https:// | ||
| - | - [[https:// | ||
Variables.1501657248.txt.gz · Last modified: by peternlewis
