For quite a while I have been using Keyboard Maestro macros to log in (using 1Password) into some "Apps" (which are single purpose browsers for services, so I can't use the 1Password extensions).
Credentials used to be stored in instance variables, but now in KM10 (with the introduction of subroutines) I converted them to local variables.
Do I still need to clear local variables, or are they "gone" when the macro has executed?
Can I combine variable types? Can I make the ones for passwords and OTP values both a local and a password variable by naming them localXXXpw?
Local variables only exist for the duration of the macro they are first used/defined in, so once that macro has ended, the value of the local variable is wiped out.
You can have local password variables, but be aware that the name of any local variable must begin with local.
Thank you for sharing this. I've seen a lot of folks here saying that local variables are case sensitive...perhaps that's how it used to be; I'm not certain though because I've only been using Keyboard Maestro for about 3 years and only this year started to use local and instance variables.
Out of curiosity, I did a search on "Case Sensitive" on the forum. Here is what I found that might be related to what you were talking about. It's not the variable names that are case sensitive, it is the token names that are case sensitive.
I’ve said a couple of times in this forum that the designator for local variables is case sensitive, so I guess this is a change brought in with KM v10 perhaps. It’s good to hear because if in v9 you used local by mistake it would still work but you’d be using a global which could cause you problems.
I’ll certainly be confirming this for myself once I get my Mac back!
Anyway - it’s good to learn something new.
Edit: I see the wiki entry was edited in October, so perhaps this is indeed to do with KM10 but the release notes make no mention of it…
There has been no change, variables have always been case insensitive, “local” has always been case insensitive.
I went back and tested it in version 8, and it is exactly as @martin showed about, “localtest”, “LocalTest”, “LOCALTEST” are all the same local variable.
No. When the macro finished, local variables are gone.
Honestly, I wouldn't recommend it.
Either use a local variable, or use a password variable (and clear it when done with it).
I don’t believe a variable can be both a local variable and a password variable, and I don’t know how it would behave in which circumstances. And if I don’t know, that means it could change in the future no matter what it does today.
That is curious indeed. I remember back in April when I started developing a complicated set of macros that depended on the use of local and instance variables I ran into problems with local variables seemingly persisting. After fiddling around (as every software developer does ) I found the solution was to capitalise the word ‘local’ in my variable names leading me to think that case is significant.