Quickly Expand The Selection To A Given Letter

I'd also like to know if it's possible to do that. But as I understand it right now, with KM you don't ask a user for a character of input, rather you let the key be the trigger for a macro. The macro I screenshotted in the post that you linked contains an image of the trigger that you would need to use. If you do that, you can access the value of the keypresses using the %TriggerValue% token. It's a different way of thinking, and may require you to rewrite your code.

A loop requires to know when to stop. When are you planning to stop the repetition you speak of?

Hi @ALYB,

@Sleepy made some suggestions for how to improve my macro that may make it faster and simpler and also may help avoid the glitch/error that I described at the end. I'll let you know when I update it, which should be in just a day or two.

Hey @peternlewis,

How tough would it be to add a key-down event to the Pause-Until action?

And then allow the user to collect the key via the %ActionResult% token or a new token?

That would open up a whole new horizon of trigger options...

-Chris

The answer may depend on whether we're asking about ascii keys or USB key codes. I'm not sure which one is more desirable to have, nor am I sure which one is easier to implement. I'm inclined to choose the latter, but then if we want to know which character was pressed (via ActionResult?), then the result would likely end up being strings like "CTRL-CMD-F10". If we chose ascii keys then the result could be a single character.

Virtually impossible.

Keyboard Maestro cannot detect all keys without either setting hot keys, or them producing key events, neither of which is practical or sufficiently generic.

@Sleepy I've come up with a solution without a loop:

2gif

I've posted the macro here: Quickly select up to a given character (repeatable)

1 Like

@peternlewis Nor is it possible to create a hotkey+letter trigger? CMD+/,r for instance?

Or create 26 shortcuts: CMD+/+letter and 26 case conditions?

It may depend what your question means.

  1. If you mean using built-in KM triggers, without a complicated KM macro to make it work, the answer is no.
  2. If you mean could KM be modified to support this: while it seems to go against KM's design philosophy, I'd say the answer is maybe.
  3. If you mean can you write a macro to emulate multi-key triggers, then I think yes. I could probably write a macro to emulate multi-key triggers. But I don't understand your question because CMD is a modifier, not a hotkey-capable key or an ASCII character. I think you would need to clarify by saying what kinds of keys (and how many) you want to be able to use in your multi-key shortcuts. If you tell me the exact, complete set of multi-key shortcuts you want to support, I'll tell you if I can emulate this in a set of macros. I'm pretty good at coming up with solutions to difficult problems like this one. But you probably won't like my solution because it will require work.

Thanks for your clarification! I thought that it would be option 3 and after some thinking I remembered a macro of @cdthomer where several hot keys can be used, and depending on the one that is used, a different action will be taken. (The Aspell macro)

So I tried this:

And it works. I can use this to avoid the Prompt dialogue box in my Quick selection macro.

The disadvantage would be that I have to reserve an awful lot of keyboard shortcuts just for this single macro…

Your code illustrates some of the things we would have to do to get multi-key hotkeys to work. If you're happy with this solution, we're all happy.

Actually, this sort of problem comes up so often, I've been thinking of a fancy new macro that handles all hotkeys including multi-key hotkeys. It would basically be a macro that intercepts all possible hotkeys, and using a dataset that the user prepares (probably a dictionary) it triggers the appropriate macro using a level of indirection. A user would probably set up hotkeys like this:

The main downside to this is that it would be the ONLY macro a user could use to set up a hotkey. If the user tried to set up any other macro to use a hotkey, then the KM palette would pop up, which cancels the automation. Basically I would be replacing KM's ability to process hotkeys with a single macro that emulates it. I'm not sure if people would want this sort of thing.

Drat...

Okay, what about a means to report what key is down in the following case?

image

As far as I know there is no available method at present.

This would require quite a bit of set-up by the user when covering many keys, but it would offer a lot of functionality and could be reused once created.

-Chris

No, there is no reporting on which condition of an “any” caused the condition to succeed. It doesn't really work in general, since for all/none variants there would be no specific matching condition, and for the others it could be one or more than match, and so the results would be indeterminate since they are all tested in parallel.

If you want to know this you have to expand it out to a While Loop and multiple If Then Else conditions.

I was hoping it'd be relatively easy to create a means to avoid that level of complexity. Most user's won't go there.

Alas...

Hey Hans,

You can read Peter's answer above for one quite complex method.

The other more simple method that I can think of is to create a conflict palette.

So your main macro when activated pops up a conflict palette with as many letter choices as you want.

The letter is returned to the main macro when you press the key, and the macro continues.

-Chris

1 Like

Hello Chris,

The idea of a conflict palette had indeed popped my mind. However:

  • wouldn't that imply a large and ugly list with at least 26 letters?
  • how to create one without creating 26 macros?

Currently I'm musing over another approach, of which I'm not sure that it's possible:

  • create a trigger macro which only function is to enable and launch the quick expansion macro;
  • add a final action to the quick expansion macro where it disables itself (to free all the hot keys used).

How about that?

Hi @ALYB,

I’ve updated my macro and I think it does what you want. When I use it I type shift + command + control + S and that pops up a Pick With List menu. The list is organized, as you have previously suggested, with a unique single letter at the beginning of every line.

Immediately before the PWL menu, I run Activate Macro Group for one action which activates a dedicated group. The group contains one macro, which has 48 triggers for the single action which outputs the trigger value followed by Return.

1 Like

I tried that approach in my earlier version of "Follow Menu Choice With Return". It worked OK, but every once in a while the macro got interrupted, didn't run properly, and so didn't disable itself. That was awkward when then triggers were normal text characters.

My newer version puts FMCWR into a dedicated group that gets activated for one action only. That avoids the problem of how to disable the hotkey set.

An even earlier approach I tried was exactly this. And yes, I created over 20 simple macros by copying and changing the hotkey manually for each copy. It uses up a whole lot of hotkeys. Jim S uses that approach in his Desktop Spaces macros:

I tried it. I didn't like it. His approach works fine for up to 9 or 10 desktop spaces but I had 21 and it was too hard to find a consistently patterned set of hotkeys that didn't have unwanted side effects like being something I wanted to use and couldn't redefine or being something where a mistyped hotkey had unpleasant results.

I still don't know if my approach will work for the original problem in this thread. Your other question about selecting from a Prompt With List menu is exactly what I was doing. Here it's a different context, and I haven't wrapped my mind around your actual problem yet.

Thanks @August, I'm afraid of that effect too. I was planning to add a timer to disable the enabling too. Besides that, I've built in several disabling actions already.

But the approach of a a dedicated group that gets activated for one action only, is probably way better (safer). I'll have a look at that. Noticed the action for the first time yesterday, but missed the click in my brain.