I'm creating a macro which uses a new technique that modifies the macro name in order to place new information on the system menu. The technique is quite interesting so I've decided to post it here before I even upload my new macros which use it (to monitor the CPU load and free RAM.)
Each KM Group has a feature called "Display in Menu Bar" that includes an option called "With Title from Variable" that lets you place a text message in the Menu Bar. That's useful enough, but I've found another trick to enhance that. For example, I've developed a CPU load measuring that places an icon on the system menu with a number representing the load, like this:
(Notice that the red/yellow/green icon colour changes dynamically based on whether the load is light or heavy.)
But I noticed that when you click on the icon, you get the name of the macros in that group below the icon.
So I was thinking, is there any way to programmatically change the name of the macro so that useful information could be displayed there in place of the macro name?
Sure enough, it wasn't that hard to do. At the top of your macro, you have to include this action:
Then during your macro you have to place the text you want to display into this action: (in this example I'm just placing a random number as the new name)
Normally you wouldn't use a random number, you would use some interesting data. In my case I'm placing the last ten readings of a system setting as the new name.
Then you execute this macro:
When you do this, the name of the macro will change to become the name of whatever data you placed into the variable LocalNewName. And when that happens, it will also place that data into the system menu, so it will look something like this:
Notice that the value I assigned to LocalNewName is now the new macro title, and therefore, is now visible under the Macro Group's icon. This is a new way (at least for me) to provide information to the user.
As a free bonus tip, which I plan to exploit, you aren't limited to ASCII characters in the name of the macro, or in the variable that you assign to the group! Emojis will also work, and I plan to use this to pass more information to the user.