How to apply a TextSoap cleaner

I have a "cleaner" defined in TextSoap. It operates five regex search-and-replace actions at once.
Then I can invoke that cleaner using a simple AppleScript:

tell application "TextSoap"
	cleanClipboard with "Apostrofa"
end tell

Note that I invoke "TextSoap" and not "TextSoap8", because that what's one does when using the Setapp version of the app.

My sequence of actions in KM is:

Type the ⌘C Keystroke
Pause for 0.2 Seconds
Execute AppleScript (and "save to system clipboard")
Pause for 0.2 Seconds
Delete Past Clipboard 0


It doesn't work.
Please, what's missing?

Two quick suggestions for now:

  1. Try using the Copy action instead of "Type ⌘C" for the first action

  2. Don't delete the clipboard at the end; that's probably erasing the script's results

I think your problem is the delete past clipboard action.

If you're doing that before you do anything with the clipboard, then you'll never see the results of the AppleScript.

So remove the last command and the results of the AppleScript will be on the clipboard.

Do you need the delete past clipboard action? Are you trying to clean the clipboard history in some way? If not, then you could just delete that action.
If you want to revert the state of the clipboard to the way it was before you ran this macro, then you need to (1) do something with the text and only then (2) delete the most recent two items on the clipboard:
i. the most recent is the result of the AppleScript which gets copied to the System Clipboard in your Execute AppleScript action;
Ii. the one before that is the text that is copied in your first action when you type the Command-C keystroke)
You could do this by adding in a paste action after the second pause, then add a second delete past clipboard 0 action.

1 Like

Thanks to both of you.
I refactored my macro. Now it does anything. It doesn't even copy my text.


I changed the last action to "Insert System clipboard by pasting".
Now it deletes my text and the clipboard ends up empty.
So discouraging!

In the end I have created a palette with all the search-and-replace macros using the built-in regex action.
This works smoothly.


Can you elaborate on what you mean by creating a palette? I'm trying to get Text Soap and Keyboard Maestro to work together, as well.


Well, that was quick, but thank God, I figured it out.

In my case, I'm programming a Stream Deck button to automatically paste the Textsoap-cleaned text at the cursor. I think the problem was in the AppleScript syntax, because this works well.


I have no idea why the option to "Display trimmed results without errors in a window" works whereas the more intuitive "Save to System Clipboard" does not. Perhaps a bug with Keyboard Maestro? No window is being opened at this action.

Great! I would've never been able to find such a solution. I will try to implement it in my macros involving TextSoap.

By the way, a palette in KM is just a set of macros. When you create a group of macros, you can invoke that group with a kyestroke, and the result is a palette where you can have other keystrokes configured.