Any Way to Show a Small Sign on Screen When a Macro is Enabled?

I'm trying to make a small sign shown on the screen to remind myself that a macro (or certain macros) is enabled.

I have tried "Show Global Macro Palette" and the Custom HTML Prompt. Each Has advantages and limitations.

The Global Macro Palette is not designed for my purpose, but it's small and fits my needs. The limitation is that because of its own purpose, I don't have much room for customization (see my comments on the Custom HTML Prompt below).

The Custom HTML Prompt is much more flexible. I can design it's background color as well as the text I want it to show. The latter allows me to show different signs for different enabled macros.
image
This is almost perfect. I said almost because there is one thing that bothers me: the KM engine icon in the menu bar is constantly flashing whenever there is a Custom HTML Prompt.

the Display Text window does not make the KM engine icon flash, but its smallest possible size is still too large for me in this case:
image

Are you aware that you can style the different types of palettes from the keyboard maestro preferences?

Yes. I am. But the Custome HTML Prompt has more advantages.

I can design it's background color as well as the text I want it to show. The latter allows me to show different signs for different enabled macros.

Do you mean "enabled", or "active", or "triggered"?
Those are all very different things.

See Macro Activation .

May I ask what is your purpose in doing so? How will you use this info?

I mean "enabled".
But this is not the main concern of my question.

I should have expressed my needs in a clearer way:

My question is about how to

"make a small sign shown on the screen"

that is small, customizable, and does not require the engine icon to constantly flash.

I'm able to use BetterTouchTool to create a floating HTML window for this purpose.

That's great. Would you mind sharing your solution for the benefit of others?

It's a bit complicated, but the logic is simple. I'll try to describe how I did it.

Create Two Macros

  • Create one macro in KM.

    • KM macro: If %TriggerValue% is "AppleScript", then disable the macro group. Else,
      • if the macro group disable, enable a macro group (or a set of macros) and then call BTT to bring up the floating HTML window (the small sign to show that the macro group is enabled). Eles,
        • disable the macro group.
  • Create one named trigger (equivalent to KM macro) in BTT.

    • BTT Named action: to bring up the floating HTML window. This is just a very small icon (screenshot below). At click, it (1) triggers the KM macro to deactivate the macro group via AppleScript (with parameter "AppleScript") using JavaScript in the floating HTML window and then (2) closes itself.
      image

Workflow:

  1. use hotkey to trigger the KM macro.
  • Result: the macro group is enabled, and the BTT named action is triggered, displaying a sign (can be anything we design).
    • BTW, BetterTouchTool allows the HTML background to be transparent. Therefore, you only see an icon above, no window title bar etc. Shout out to @avialan who has just made a feature request for Translucent Custom HTML Prompt for KM. :wink:
  1. If I want to disable the macro, just click this sign. It will call Keyboard Maestro to trigger KM2. Then it closes itself. The cycle is complete.

Floating HTML in BTT

The key is the floating HTML prompt in BTT. Thankfully, BTT has already provided an excellent example here (See especially the example: "Transparent webview that displays a fancy action menu"):
https://docs.folivora.ai/docs/10_0_floating_html_menu.html

Edit: Made some improvement. only one macro needed for KM and BTT respectively.

2 Likes

ahh, so that must be where I got the idea.

Thanks for your explanation @martin :+1:

I use the BTT HUD display very often in my KM macros, as I really appreciate the centered display for actions.

Here is an example how I start the recording of my internet radio in the background and the BTT HUD Display confirms me the execution of the KM macro.
Thanks to the (free) app AnyBar, the recording in progress is shown to me in the Menu Bar.

2021_03_08_Support_4

The developer was kind enough to provide an AppleScript for the HUD display, so that I can easily integrate it into any KM macro.

    tell application "BetterTouchTool"
	
	trigger_action "{\"BTTPredefinedActionType\": 254, \"BTTHUDActionConfiguration\": \"{\\\"BTTActionHUDDetail\\\":\\\"start\\\",\\\"BTTActionHUDTitle\\\":\\\"๐ŸŽ™\\\",\\\"BTTActionHUDDuration\\\":\\\"1.4\\\",\\\"BTTActionHUDBackground\\\":\\\"38.719535, 38.720697, 38.720067, 213.662109\\\",\\\"BTTActionHUDSlideDirection\\\":4}\"}"
	
end tell

The HUD display is also very helpful to show the next steps (shortcut, keyboard keys) for further execution of macros that are not used so often.

4 Likes

Thanks, @appleianer.
This looks very nice. It meets my needs. I wish I knew it before. I may use this instead. But I'm glad I had another successful attempt in integrating KM and BTT.

Hey @appleianer,

Does this script still work for you? I can only run it, from Script debugger, when the full BTT app is running. Otherwise, I get nothing. It used to work but no more.

Thanks,
KC

1 Like

@kcwhat it still works fine for me.

2022_02_23_Support_1

tell application "BetterTouchTool"
	
	trigger_action "{\"BTTPredefinedActionType\": 254, \"BTTHUDActionConfiguration\": \"{\\\"BTTActionHUDDetail\\\":\\\"next\\\",\\\"BTTActionHUDTitle\\\":\\\"Escape\\\",\\\"BTTActionHUDDuration\\\":\\\"1.2\\\",\\\"BTTActionHUDBackground\\\":\\\"38.719535, 38.720697, 38.720067, 213.662109\\\",\\\"BTTActionHUDSlideDirection\\\":4}\"}"
	
end tell

Thanks for your test and response @appleianer. This no longer works for me. Other AppleScripts work fine. And this one works, from the Script Editor, as long as the BTT app is open and in focus. If looked in the Sys prefs Accessibility/Privacy sections and played the remove/add game. No dice. I contacted the developer weeks ago. Iโ€™ve thrown in the towel. :grinning:

Thanks though!

@kcwhat, that's weird :thinking:
Is this just because of the HUD display script? Do other BTT AppleScript in KM stop working as well?

Is this setting in BTT is enabled?

Hey @appleianer,
So far itโ€™s just the HUD script. I only have the one AppleScript BTT script. My setting is the same as yours. It has to be something else. Because of the nature of how it runs.

At the time I asked the question, my knowledge of the Custom HTML Prompt was much more limited. Now, with KM10, we can hide the title bar and use translucent background. KM should be sufficient for most use cases.

Hello @appleianer,
I managed to figure out the issue. I had the BTT app only open on a certain desktop. So any HUD overlay would open on the same desktop - regardless if the BTT app was open or not. When I moved the declaration to All Desktops, the HUD shows fine everywhere.

Screen Shot 2022-02-25 at 2.47.15 PM

I have Keyboard Maestro and other applications, on certain desktops, but the notifications, alerts, displays and prompts work everywhere. I'll chalk this up to a lesson on difference of opinion. :slight_smile: The HUD Overlay should work on any desktop, IMO.

Thanks for your testing.

KC

1 Like

@kcwhat you have to come up with that first. I was really surprised that you had problems with the HUD display. You really never stop learning.

1 Like