"Group becomes available" trigger + macro group option for "available while macro is executing"

As I’ve realized that it was triggering upon macros in group getting available, more than upon group activation, I've changed the threads title, and rewritten this post better to reflect this. A Group Activation trigger could also be useful, but Group Getting Available trigger would bring with it more unique usability.


I’ve many times found myself thinking, and also mentioned here before, how a Group Activation trigger could be very useful; triggering a macro when a certain Macro group Activates, or Gets Available. Oftentimes it would be used to trigger a macro within the group having become available, so an option for 'When THIS Macro Group Gets Available' would make allot of sense. But this trigger would ideally also have options for selecting the macro group from a list of all groups (similar to the how it’s done in the Activate/Deactivate Macro Group acton). Different trigger settings for when the selected (or THIS) group "Gets Available" and "Unavailable" (as well as "Activates" and "Deactivates") would be great.

In the context of this trigger I believe I view change of group availability status as being the same as activation/deactivation. So maybe it could be combined into the same trigger/setting, and would trigger just the same if the group was activated by a hot key or an a Activate Macro Group action, as when it becomes available by bringing a certain application or window to the front, (or the like). The %TriggerValue% should ideally differentiate between the two though, as well containing details about the event activating, deactivating or altering the groups availability status.

If there'd be an option for 'When THIS Macro Group Deactivates' I believe it could make sense for the macro to be triggered and ran (once), even if it’s group at this point is in fact deactivated, but I see how this specific behaviour is somewhat strange, and I am not at all sure about this one. I am also not sure if 'When THIS Macro Group Get Unavailable' would here pose the same problems as Deactivates, maybe not?



A somewhat mirror-related feature to the one above that I’d also find very useful, is a Group Availability option (in the Macro Group settings) for "while Macro with UUID is executing". Ideally the field for adding the UUID should accept several UUIDs separated by commas, making it possible to add more macros than one. I guess it could also be very useful if there where options for "Available when a Macro with name contains/matching is executing". When thinking about it now it could also make allot of sense for there to be an option for "Available while any macro in group(s) with UUID/title is executing", making it possible to add availability for several macros through adding them into a certain group or groups.

2 Likes

I also vote for this new token, and propose that its value be the constant bouncy.

7 Likes

Just kept laughing for several minutes by reading your comment and now my stomach hurts from too much laughing by watching the Tigger Song Video in English….

I’m very lucky if I see posts like this - a day without laughing is a lost day …

Many many thanks Nige :pray: :pray: :pray:

Greetings from Germany :de:

Tobias

3 Likes

When posting videos like that, please include a Tigger warning.

1 Like

But does anyone else, besides me (and I guess maybe @Dmitriy_Davydov from the thread I linked to), see any value in my suggested features?

Tigger for attention

Personally no -- it's probably short-sightedness on my part, but I'm struggling to find a situation where I'd use it. Perhaps a couple of use-cases would help?

There may also be technical issues -- activation can happen for one action. KME may not be able differentiate between that one action resulting from a "macro group activated" trigger and any other. That, plus the deactivation conundrum you've already mentioned, could make for behaviour that is inconsistent with other areas of KM.

Well, here is my example. Before some recent changes I was keeping my shortcuts dedicated to a web page in one macro group. This macro group was activated when the specific site was opened. One of those macros was a macro that injects a JS script in the web page content and registered there some additional functionality like this one: Marking files as "Viewed" with keyboard shortcut · community · Discussion #10197 · GitHub.
This placement inside one group were keeping related things in one place, which was nice.
Now I have to keep my page injected scripts in one macro like that:


Which is tolerable, but still not tidy enough.
However, there might be more use cases that are based on macro group activation.

How were you doing that? I'm not trying to be picky or pedantic, but there's a difference between a Group (and thus its contained macros) being "Available" and being "Activated".

I‘m sorry Alex (@Alexander),

I totally forgot about that I wanted to make a reply to you about my thoughts… that was not my intention…

While I am thinking that a Trigger like Macro Group xxx activated / deactivated could be useful in some cases I am also thinking about what Nige said…. There are maybe some things that could happen to already existing features in KM whose could maybe break their functionality…

Despite the fact if Peter would ever implement such a Trigger or even all the features you described.

I for example always have only Macros enabled when they are needed, despite one category… and that’s my Engine Helper Macros Category. In this Category of Macros are even potentially needed ones enabled.

A short example here:

Application Launches: All Macros with this Trigger are enabled as long they belong to the Mac (where the Applications are installed on), and the Applications are not running. The macros with the Triggers Application Activates/Deactivates & Quits are all disabled. If any Application launches, its Macro enables the dedicated Applcation Deactivated & Application Quits Macros and makes everything else available that’s needed in the context the Application is running in. As a it’s last step the Application Launches Macro disables it self.

Back to this reply:

I hope this gives you a bit of insight on how I Use KM‘s capabilities… why did I told you that? Because I think it’s quite better to enable / disable / activate or deactivate a Macro Group or Macros in preparation to the tasks they were created for and have them available only until the task is done.

This approach is maybe sometimes a little challenging to accomplish but I think it is able to realize in every context.

And what I also think is that this approach is by far more reliable and easier to maintain and debug because I ensure that if a Macro is not a Helper in the Background it won’t ever be able to run unintended.

I also think Enabling of Disabling Macros and Macro Groups is better then Activating or Deactivating them because if you Enable A Group you are in charge to decide which Macros in that Group you want to have to be enabled and which not.
If you Activate a Group all Macros in that Group are active without any compromise.

Dmitriy (@Dmitriy_Davydov),

A thought about your example and my approach to solve the question of when something has to be available and when not …

Why don’t you make sure that your JavaScript files are running in preparation to the Task you want to do ?

If I where you I would not build a Macro like that … pretend you have more than 5000 domains …

I would at first side think about categories for my JavaScript code, then create a file for each category.

Each Category should handle several different domains based on that particular category the script was written for and there should be parameters which are able to be set by KM.

And finally I would then put the code into a Macro that is using the Parameters for this code when it is needed.

Remember that this are all only suggestions.
Nothing I said here is a MUST.

Greetings from Germany :de:

Tobias

This isn't an exclusive choice, though -- you can have a Group that is enabled on a contextual basis and then activated/deactivated after certain events. An obvious use would be a palette Group that was only available in a certain app and then only active after a certain keypress.

But so far I've used context or macros for that kind of thing -- no need for an activated/deactivated trigger because I could proxy on the method. So I'm interested in cases where that can't (or is more difficult/messy/whatever) be done.

Hey Nige

This are my thoughts and suggestions you are referring to…

I’ve done nothing more than suggesting that I am doing this kind of thing… I also suggested an example on how I do it.

Greetings from Germany :de:

Tobias

Of course -- I'm just pointing out that we can Enable/Disable Groups, then have them Available/Unavailable, and then Activate/Deactivate them.

There's room in there for a lot of confusion -- I'm not sure, for example, how @Dmitriy_Davydov was activating a Group when a specific site was opened because that's usually something you'd do via "Availability".

Yes, sorry, including that in a reply to your post made things unclear. I'm interested in anyone's use case for an "on Group activation" trigger -- about the only thing I can come with is to trigger a macro that (re)sets palette positions...

Firstly I believe I've used the term 'Group Activation' too loosely in this thread, realizing that it is more often changing of group Availability that is the event I'd like to trigger a macro upon. I should probably changed the threads title to better reflect this.

But the way I've been thinking about the usefulness of a group activation trigger (or changing of group availability trigger) is that the event that activated (or made the macros in a group available) would oftentimes also be desired as a triggering event for a macro within that same now activated group.


Using the 'Available when a focused window title contains: "YouTube"' as an example:

If I'd want to have a macro doing a job every time I am entering a YouTube-page I could use a ‘Focused Window Trigger: The focused window title changes’. But even with that macro being within a group only available in Firefox this macro would still trigger every time an active Firefox window changes it's title. The actions within the switch would only be executed if the changed focused window title contains "youtube" — but still, this macro would trigger pretty much every time I'd enter a new internet site. I have a macro quite similar to this running, and I probably don't need to tell that this macro triggers with very high frequenzy.

A — Storing a count of YouTube clicks together with lates URL.kmmacros (6.0 KB)

Macro Image


In an attempt to counter this hyper-triggering one might try to use the macro group setting 'Available when a focused window title contains: "YouTube"'

But sadly, as the macro group would first be active when having entered a YouTube-page, this example macro would only trigger when moving from one YouTube-page to another:

B — Storing a count of YouTube clicks together with lates URL [in YouTube group].kmmacros (6.0 KB)

Macro Image

My suggested 'Group Activation' trigger (or 'Changed Group Availability' trigger) would solve this by making sure the macro was triggered by the same event that made the macro(s) in the group available. I am sure there are other ways to solve this, and the hyper-triggering version of the macro-setup also works, but in my idea a 'Group Trigger: When THIS Macro Group Activates' would just makes allot of sense.

Triggering on group deactivation are probably over-complicating things, and where maybe silly to mention, but the 'Group Activation' trigger (or 'Changed Group Availability' trigger) sounds to me like something that might be practically possible to implement. And as it would be implemented as a new trigger there would maybe not be any danger of it altering the functionality of already existing macro either?

Gotcha. Thought it might be something like that.

While I understand the desire to reduce "pointless" triggering (and fully endorse the request for a "Group becomes available/unavailable" trigger :wink: ) -- is there an actual problem with macros triggering with such frequency? Sure, lots of "unnecessary" triggers recorded in the Engine log, but the resource cost is next to nothing compared to everything else going on.

But -- out of interest -- try changing the setup you already have so that Group availability remains the same but your "Storing..." macro's trigger is "The focused window's title changed". That should pick up the cases that your trigger doesn't while limiting false triggers (for me it doesn't even fire when leaving YouTube...).

Not a universal panacea but, if it works, it might help in some cases.

1 Like

As stated in my now edited first post of this thread, I've updated that post, and changed the threads title, better to reflect it being triggering upon macros in group getting available, more than upon group activation i am wishing for.

I sadly does not have that much time to spend by my Mac these days (also sorry for the late reply), but from the quick testing I did here now changing to "… window's title changed" does indeed remove the false trigger upon clicking away from youtube with my example macro B (the one in a the group only available when the focused window contains "YouTube". But apart from this it seems to me to trigger the same as with trigger settings set to "… window title changes". The biggest problem still being that the same B-macro not triggering when first entering YouTube, (only triggering when the window title changes from one containing "YouTube" to another)

That's a shame.

It also appears specific to Firefox -- it works for me on both Safari and Chrome, but not in FF. Looks like it handles new window titles pre/post YouTube-loading differently to the other browsers.

To be more specific -- neither Safari nor Chrome work when going to www.youtube.com itself. But they both work if you go to a video, eg https://www.youtube.com/watch?v=ZwfHw7i9FTI

For me, at least...

1 Like

Here is an example of a hack to trigger a macro whenever its macro group is activated. It uses the periodic trigger being set to its shortest interval, which is 1 second. :scream: Of course, we don't want the macro to be triggered more than once, so it ends with an action to disable its macro group. Right before that, it enables the complementary macro group – which can re-enable the first group.

As I said, this is a hack… but the example works.

:warning: If anyone wants to experiment along these lines: heed the warnings on the Wiki page about setting a short interval for the periodic trigger.

The first group is "Firefox tab == YouTube".

The group contains this macro:

The second macro group is "Firefox tab != YouTube":

It contains this macro:

1 Like

May I suggest the following?

"Group becomes available" trigger + macro group option for "available while macro is executing"

1 Like

Yes, this is a shame.

Sadly I’ve become accustomed to some features and add-ons not present in Safari, and I do not want to use Google Chrome. But as I am feeling more and more limited by Firefox I will at some point look seriously into swapping my browser of choice. When (if) Orion matures I believe that one might be it.

Thank you, edited my title to this suggestion, much clearer than my phrasing!

Thank you also for the hack work around you posted! It looks interesting and I’ll check it out more thoroughly tomorrow once I am back by my Mac.

1 Like