Howdy folks, I thought I would share a simple macro that has saved my bacon a few times.
I like to use typed strings for certain kinds of macros, but as everybody knows, if you want Keyboard Maestro to delete that string, it can cause issues depending on what app you're in. God forbid you trigger a macro like this while you're editing a macro because you could end up deleting a bunch of actions haha.
So what I do is unselect the option to delete the typed string in whatever macro that uses them. Then, as the first action, I place an "Execute a macro" action using a parameter that matches however many characters the typed string is.
For example, I have a macro that closes all Safari windows whose trigger is "csaf". So I put an execute a macro action at the beginning of it with the parameter "4", and then this macro will use that parameter to delete that number of characters but only if certain apps are at the front (primarily text editors and others who are not affected by the delete character). In the "matches" line you can put in whatever apps you want that you don't mind the delete key being simulated, separated by a RegEx alternation character.
It's not fancy, but it works well for me and maybe will help others too.
EDIT: Updated to use RegEx to match front application instead of a list of applications. Thanks to @tiffle for the tip!