Variables that persists?

Do the variable persists even after the KM engine quits or computer is shut down? If not, is there another way to store values indefinitely and pass them to a variable or macro?

I want to set a different flag color each time a certain Mail macro is run. It can be days or weeks between each run so I want to store the last flag color until the next run.

Hey @veramilo,

Why don't you test and find out?  :wink:

Make a variable with content.

Quit the Keyboard Maestro Engine from the Keyboard Maestro Editor.

Quit the Editor.

Restart the Editor which will also restart the Engine.

Look in the variable pane of the Editor's prefs.

-Chris

Yes, they persist.

As Chris pointed out, you can check your variables by going to “Keyboard Maestro->Preferences” and selecting the “Variables” tab.

Thank you. Yes, I know I can test, and I would have if no one already knew the answer. I shouldn’t have even mentioned quitting the engine because what I really needed to know is if it persists through a reboot (which also quits the engine). Rebooting takes way too long on my computer so I only do it once a day (unless I crash, which is rare). This means I wouldn’t have my answer until tomorrow while the macro is on my mind today. That’s why I was hoping someone already knew the answer. Thanks again.

No problem. I totally get it.

And yes, they variables survive reboots, etc. It’s quite common for people to depend on variables retaining their values. I know I do. So you’re on solid ground here.

https://wiki.keyboardmaestro.com/Variables

That's strange. When I skimmed over that Wiki article, I totally missed the part that talks about persistence, even though it's the second paragraph:

Is it just me (my wife will tell you I'm blind when things are right in front of me, so it may well be me), or should this be highlighted more clearly in the Wiki entry?

@JMichaelTX - What do you think? It's just me, isn't it? :blush:

Now I’m stuck again. I can set the variable but I can’t find an action to read the value of a variable. What I want to do in Mail is set the flag on a message to blue if the variable “lastFlag” is red. If “lastFag” is not red, then I want to set the flag to red. I know I can use variables in tokens, but I can’t find how to use tokens to accomplish what I need here either.

FYI: I’m still relatively new to KM.

LOL. Yeah, I got that. :slight_smile:

Use the "if/then/else" action, and select "Variable Condition". See if that helps any.

AHHHHH – it’s under the plus sign! That dang icon fools me every time. I keep thinking it just adds another line. Thanks!

I totally get that! It takes a while to get used to how the UI works.

By the way, if you haven't already, try using Control+Command+A when you want to find an action to insert. You can search for actions that way, and in my opinion, it's a lot easier to find what you're looking for.

Not that it would have helped in this instance, but I think it's a good tip anyway.

Thank you for the tip. I do sometimes search for actions that way, but mostly I use the search field just because it’s the most obvious. As I use KM more, I may get more used to that command, too.

I created my macro and it works perfectly. Thank you for the help!

I thought the Wiki was pretty clear, but on review I found it could be improved (hopefully).
Personally, I more quickly absorb information when it is in a list. I hope that is true for most.

Check it out:
Variables [Keyboard Maestro Wiki]

Awesome. Much better. Thanks!

1 Like

I hope this is a typo and you mean “only once a week”…

It isn't a typo. I have a Mac consultant friend who told me it isn't necessary to shut down every night but that there's no harm in it either. And that's been my experience: I've been shutting down practically every night for over 20 years with no ill effects. But as I said, I do not shut down more often than that if there's anything I can do to avoid it.

1 Like

Since you mentioned —in the same sentence— the inconvenience of rebooting (“takes way too long”) and the “once a day” (which is a pretty high reboot frequency for me) I thought this must be either a typo or you have stability problems with your Mac.

But your Mac consultant friend is certainly right. I usually only reboot when there are issues or when an install/update forces me to do so. (Currently the last reboot was 9 days ago.) I shut down the desktop Mac only when I’ll be away for more than 2 days or so.

But I have to admit I have (and almost always had) only “low power” Macs (like MacBooks or Mac Minis) which presumably have a low sleeping power consumption. More important to switch off external monitors over night. If one has a Mac Pro or a G5 tower or a Hackintosh energy savings may be significant over the years.

In fact, I just realized that I actually don’t know much about how other people (Mac users) are handling this. Most of the people I meet IRL are on Windows, and those are rebooting / shutting down quite often.

I have a 21.5" iMac that I leave on all the time, although it sleeps after an hour. I have an external monitor attached. The monitors sleep after 15 minutes. 2 external hard drives, one for Time Machine.

I only reboot when I think I need to. Since I have a fusion drive, reboots are pretty quick, although they got significantly slower with El Capitan for some reason, but still take less than a minute I think (haven’t really timed it).

I’ve been running this way for, I don’t know, 4 years or so? I won’t say anything about not having any problems doing this, because that would be tempting fate. So remember, I did NOT say I haven’t had any issues. :slight_smile:

I started doing this back when I had a Mac II (1988) – and I would sometimes even shut down more than once a day if I thought I’d be away for more than a couple hours. It would heat up the room too much in the summer, I had no a/c, and there was no sleep mode. Now it’s just a habit to shut down. I do set my system to startup at the same time every day – before I’m normally ready to work – so at least I don’t have to wait for that. It’s no interruption to my work this way. It’s still running (or in sleep mode) a good 12-18 hours a day.

1 Like