How to display realtime info about a variable


#1

I would like to have some sort of window that displays in real time the value of a variable.

I recently wrote a simple script to mute my microphone, then displays the input level (0% or 100%), but sometimes I might forget it it's currently muted or not. Therefore I'd like to see that value without running the macro again.

Any ideas?

FWIW the variable I would like to display is called "Microphone Level".


#2

As long as the KM Variable is NOT a Local or Instance variable, you can use the Variable List/Panel in the KM Editor Preferences:

image


#3

Yea I'm aware I can access them there. I actually have another macro that pops up a list of a lot of my most often used variables and allows me to change them. But I would like to incorporate this into two other macros that way it will pop up once a particular macro has run and disappear once another macro runs.

Hopefully that makes sense haha.


#4

Sorry, I'm not clear on what you first macro is doing, or how you want to use it in other macros.

The KM Preferences > Variables Panel is the only way to make KM display Variable values dynamically as they are changed. An, of course, it requires that you have the Keyboard Maestro.app open.

IAC, here is an UN-TESTED idea:

  1. Write a simple macro that only displays in a Display Text action the Variables of interest.
  2. Call this macro (which I refer to as a "Sub-Macro") from any other Macro using the Execute a Macro action
  3. Close the KM Display Window using AppleScript UI scripting when you are done.

I'll stop here until you confirm this is what you want and need further help.


#5

Thanks for the quick responses. I'll give you a breakdown of what I'm trying to accomplish so it makes more sense.

I do telephonic interpreting. I have a macro that answers my incoming calls for, pulls up my work windows etc. I have another macro that hangs up the call and closes my work windows etc.

I recently wrote an Apple Script to mute/unmute my microphone that I run from Keyboard Maestro that way I can quickly mute the microphone in case I have to cough or something. It's an "all in one" script in the sense that if the mic level is 100 it sets it to 0, but if it's 0 it sets it to 100. Very simple; works great. Through Keyboard Maestro it saves the result (0 or 100, the current level of the mic) to a variable called Microphone Level.

What I would like to accomplish is write a sub-macro that will display that variable in realtime that way I can always see if it's muted or not. I would embed this sub-macro into my "answer call" that way once I answer a call it will run and constantly show me the microphone status. Then once I run my "disconnect call" macro it will close that window showing me the microphone status.

Does that help?


#6

This displays a Notification that shows the variable's current value when you hit the trigger:

ss-909


#7

KM will only display a static value of a Variable at the time of execution.
So I would simply Display the Mute Status in the Mute Toggle macro when the mute is toggled ON.
Remember that you can use rich text in the Display Text action, so you can make it as big and bright as you like:
image

One thing you will have to do after the Display, is to set focus to some other window so you don't accidently press RETURN and close the window.

If you want more control over the window, you will need to use Custom HTML Prompt action.

When the Toggle is to un-mute, then close the Display window.

To close the KM Display Text Window, put this script in a KM Execute an AppleScript action


#8

Version 9 will have a Value Inspector:

Alternatively you can write an Custom HTML Prompt window and that can display live results.


#9

Peter, is this an Action callable from a Macro?


#10

As Peter mentioned, using a HTML Prompt would give you more flexibility. See


#11

No, it is an editor feature, a window like the Mouse Display or Macro Inspector.


#12

@peternlewis,
Then that really won't help us that much. We desperately need a dynamic display that is callable in a Macro.

What would really be great is a display of either a list of variables, or all variables with a given prefix. And this needs to work with Local and Instance variables, as well as a Dictionary (show all keys), or Dictionary.key list.

Thanks.


#13

Thanks for that info. Unfortunately it's a little past my skillset. I haven't messed with HTML in 15 years now haha.


#14

I use a program called √úbersicht to display information on the desktop.
See this post:

One of the widgets is a text file, which gets update via a KM Macro.
So this is one to display the contents of a variable.