I'm not sure why you call that "hard", since that's exactly what the macro I wrote (above) does. My macro shows a tooltip window regardless of which app is currently frontmost. So maybe I don't understand your point here.
my point was specifically regarding showing a macOS-native tooltip - the kind you see when hovering over things in Finder or other systems apps, which don't pull focus away from the current window/selection/text field. apparently, this is very difficult or nearly impossible to do without hacking something for it into the apps themselves (adding code hooks via API that'd allow Keyboard Maestro to send data to the app to display a tooltip using the same functionality as the app does natively).
What if it took the focus for only a tiny fraction of a second and returned it to the frontmost app after that? Would that be ok? The user would barely notice. I think I can do that, but I don't think this action can pop-up without ever taking the focus.
aha! now you see why i said it's the hard part.
therein lies the difficulty, and the key difference between showing a tooltip and showing any other type of window near the mouse cursor: the loss of focus on the current window/activity.
and FWIW, i can probably list at least 5-10 cases i've had where losing focus at a point where I'd want to display a tooltip would be problematic, and result in some amount of frustrating tedium.
and that is the reason i'm still searching for a viable solution to this problem (showing tooltips in conjunction with KBM macros running) after over 2 years.
Is this because you are worried about performance? I would rather wait to see if the performance is bad before trying to optimize a solution. Functionality first, optimization second. I don't think performance will be a problem here.
not a problem for performance of KBM per se. But on any given day, i'm generally using some very hungry apps/processes (professional video/audio work, AI algorithms, etc), so i try to build optimization into everything i do based on each thing's scope/performance requirements. and for this non-critical, semi-cosmetic, asymmetrical functionality, it would be perfectly adequate to check and compare the mouse cursor location with the value saved for it when the macro starts - at most - 5-6 times per-second.
in fact, i actually already have an abstraction set up for this very thing that i could pretty easily add into the tooltip macro. it just repeats a loop indefinitely, comparing the value of one passed variable to another, waiting for a condition (passed as a 3rd argument) to be validated, and returns true
and ends the loop once it is. i also added a 4th optional argument to change the frequency (time delay between each iteration through the loop).
Do you want the tooltip to stay stationary, or follow the mouse? (I've already tried following the mouse, and it's not very smooth, so I don't like it.)
definitely want it to have a static location near the mouse cursor when it is called - just like a regular tooltip.
Believe it or not, sizing a window to fit the text is an EXTREMELY difficult task to get 100% right.
actually, i've already solved this issue as well.
basically, i have an applescript that uses objective c to draw and size a window to the font & character width and row height of a given text within a text object attached to it that looks almost the same as native macOS tooltip (minus the drop shadow, and the animated fading in/out).
there's just one minor problem with this script: it'll only work when i run it within the Script Editor app! I've tried numerous ways of getting it to work from within a KBM macro to display the tip window in the current context of the frontmost application. all attempts have failed.
so again, the hard part - the main issue i'm [still] seeking a solution for here (as indicated in the title of this thread) - is the inability to display an actual, honest to goodness tooltip when running a KBM macro.
Wow, that's a difficult requirement. If one copy of the pop-up macro is already running, you want the second one to somehow trigger the first one to stop what it's doing, clean up, and then let the second copy take over. In other words, you want the first one "polling" to see if another copy of the macro is attempting to start up. I like a challenge, so I'm pondering this, but it's very tricky.
actually, this is the standard functionality for tooltips. utilizing the tooltip class with an empty string, or some other string, causes any existing tooltip to close and/or reopen with the text of the new string at the current relative mouse cursor position respectively.
i also have this working with objective c via applescript. but unfortunately, it seems the problem lies in osascript being used by KBM to run applescripts. so i still can't get my pseudo-tooltip working outside of script editor.
with AutoHotkey on PC, there's a simple function to use to show a tooltip. it'll work within just about any other Windows app, and it doesn't steal focus - not even for a millisecond. it's just a shame Keyboard Maestro and macOS don't share a method to implement the same functionality.