Can I pass a parameter to `Typed string trigger`

I am trying to have different values in a typed string trigger. I want to open a webpage with the string passed.

My typed string 'wbx' is set to and if I type wbx aaa , I would like it to epand to

How can I achieve that?

I'm not quite sure, but as far as I know this is not possible, because "wbx" is executed after typing x. A workaround would be the sufix "space space", for example

wbx space space
wbxa space space

Or use "wbx" for both, then a conflict palette will appear from which you can select the desired macro.

About the closest solution I can think of is one that would put up an input prompt, letting you quickly type 'aaa' and then acting based on what you did (or did not) enter:

Download Macro(s): _TypedStringTriggerTest.kmmacros (3.5 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 13.6.5
  • Keyboard Maestro v11.0.2

The only other option would be to make new typed string triggers for 'wbxaaa', etc. but you'd then have to change the base one so that it opens without any parameter.


I have a wildly different solution. My solution does, I think, exactly what the user wants, but using hotkeys instead of types string triggers.

I briefly tested my macro. It seems to work fine in my tests. But it may have some unintended side effects. Feel free to try it.

Keystroke Checker Macro (v11.0.2)

Keystroke Checker.kmmacros (15 KB)

If you’ll be open to modify your key combination slightly, dropping the Space before the additional "aaa" in your example (and possibly having to manually tap the Return key), it sounds to me like you could get quite close to your request by setting it up as something as simple as this:

Opening webpage from typed string trigger- accepting aditional typing of in url-field SIMPLE.kmmacros (4.2 KB)

Macro image

With the 'optional feature' group at the bottom disabled, you’ll have to manually press Return to open the webpage. Or alternatively, before pressing Return, you could here type the additional parameter (e.g. your "aaa") straight into the already focused url-field in your browser (set to Safari in my example).

With the 'optional feature' group enabled, you’ll have ~0.6 seconds to start typing your additional parameter before the return key will be simulated, and the webpage opened. This 0.6 value in the Pause Until needs to be adjusted according to your preferences — striking the best balance based upon your typing speed, time needed to deciding if you want to type the additional parameter to your url, and time it is acceptable for you to idle to progress.

If you’d like to have the option to expand the macro – allowing it to handle more trigger/webpage-combinations within the same macro – it could for instance be set up like something resembling what I’ve done here bellow:

Expandable version of same approach

Opening webpage from typed string trigger- accepting aditional typing of in url-field EXPANDABLE.kmmacros (6.6 KB)

Edit: Doubled the IDLE() value in the uploaded macros to a more sensible 0.6s

Here's another approach — The approach I was originally going for when I realised that what was requested could possibly be solved more sensibly by my much more simplistic approach, posted here above. I still believe this is the case, but as there are some interesting ideas here, I anyways wanted to finalise this here approach also. It have some similarities with @Airy's approach above, here done with a very broad typed string trigger, in a separate 'type-logger’-macro only enabled when absolutely needed — so that it does not trigger for all typed characters, all the time.

Sadly, apart from being 'interesting' the macro's function is not all that it should be. Even though I've made the 'type-logger' as slim as possible, I still have not been able to make it record the additional typed characters as reliable as it should for this approach to be really useful — mostly a problem when fast typing, but still. I think something resembling this approach could be made into a great expansion for many Typed String triggers — and I'd really love it if anyone have tips for how the 'type-logger' could be made more reliable, or ideas as to why it is not working as reliably as I'd expect, in the current configuration.

Anyway's here's the macro-pair making up this almost functional approach:

Opening webpage from typed string trigger- ACCEPTING ADDITIONALLY TYPED URL-SUFFIX v1.1.kmmacros (17 KB)
Opening webpage from typed string trigger- recording of additional url-suffix — TYPE-LOGGER v1.0.kmmacros (3.5 KB)

Macro Images

This is why I generally wrap my type expansions in an easy to type character (I use =, but any character will do). This also avoids accidentally picking triggers that occur unexpectedly within words. Then you can your strings would be

  • =wbx=
  • =wbx aaa=

I use the character on both sides, but really only the trailing character is needed.

Note also that you can use regex in Typed String triggers, so you can include a parameter explicitly, such as =wbx.*= and then deal with the parameter in the macro. For example, I have a macro that triggers on =calc=.*= so I can perform calculations, eg =calc=2*3*4*5= gives 120.

1 Like