I'm trying to understand if this is possible:
I have a macro that Inserts text by pasting. The trigger happens when a string is typed. Example of string:
Is it possible for the output of the text to be dynamic and take each dash-separated part and produce text depending on that? In my example I have for the second part: "hos" which should translate into 3 separate chunks of text like this:
"hello world, ownership and system"
If I were to have more it would be intelligent to output every word basically listing whatever initials I type on that part. I would feed a list of mappings for each word (e.g. h= "hello world", etc.).
The same for the second part ("le").
The last part would be a date "between 10:00 and 11:00" kind of thing.
I can extend more, but I believe that I will be able to come up with the rest of this if it is even possible. I'm assuming I need some sort of script to make this happen?
EDIT: a bit more context on what I want o to achieve. I have a text template that I need to fill with at least 3 parts with dynamic strings. In the first part, I need to add a list of things (which could range from 1 to 10 following my above example), in the second part I need to add one of several sentences that depend on the set of characters I have on the second dash separator section and on the last part I need to have a date range.
If I input the example above:
I need to output:
There is something I need to do. I need to "hello-world, ownership and system". I believe "listening and ending" should sufice. This is to be done between "10:00 and 11:00".
I understand this is not possible because the input trigger string would be dynamic but:
it will always start with:
and end with (forgot about this part above):
Knowing this, is it possible to trigger something that parses the "insides" of the inputted string and produces text accordingly?
Is there any reason why you can't have
as your trigger, and pop up a Custom Dialog to enter the other parts into KM variables? You could then use "Switch/Case" actions on each variable to build the string you want to insert.
If you are open to a slightly different approach, I think Keyboard Maestro would handle this in a simpler way by using a Prompt for User Input. In the Example Macro below I had the trigger as "qqq" but you can change that to any string you want such as your "`kgi-"
One advantage is there is nothing to remember apart from the initial trigger.
EXAMPLE Dynamic Text Expansion.kmmacros (3.9 KB)
Click to Show Image of Macro
EDIT - Looks like @Nige_S has had pretty much the same idea
You could do it with typed triggers where it is a regular expresion.
So your type string could be `kig-.+
And then in your macro you use the token TriggerValue and evaluate it on what your text should insert.
Below is a macro I use to quickly write e-mails of my colleagues. Maybe you can use that as inspiration.
Skabertrang e-mail Macro (v10.1.1)
Skabertrang e-mail.kmmacros (2.9 KB)
Thank you for all the responses! I'll give a look a each one and provide feedback later on what path I'll choose.
Oh, that's nice...
I either didn't read this bit in the manual, or didn't properly appreciate it... I've been thinking I wouldn't be able to do much with text expansions because I'd never remember them all, but this could really help me out.
And OP could use
to keep to his original spec.
Hi everyone and thank you for helping me. I ended up following @Zabobon suggestion and asking for user input through the Prompt for User Input!