Calling TextSoap Agent using AppleScript

178 views
Skip to first unread message

Potts Jeff

unread,
Aug 5, 2022, 12:54:34 PM8/5/22
to TextSoap
I am trying to call Textsoap 9 agent from within DEVONthink Pro 3 using AppleScript.

I use the following code;
tell application "textsoapAgent" 
             cleanText with "Annotations" 
end tell

But it returns no effect. My normal workflow would normally be to click into an open text  document, then choose "Annotations" (my cleaner) from the Agent menu and it applies the  custom cleaner.

Not being an expert in AppleScript, have I mis- interpreted the structure?

Mark Munz

unread,
Aug 6, 2022, 12:20:48 PM8/6/22
to TextSoap

When using AppleScript, you need to get the text from DEVONthink Pro, then use the textsoapAgent to clean it, and finally put it back within the app.

It does not trigger the menu as a user might. The menu action actually uses keyboard to copy text from the current app, clean the text, then paste it back in.

This sample script better explains how cleaning works within AppleScript. Here we start with "This is some starting text" and then newText will be "THIS IS SOME STARTING TEXT" 


tell application "textsoapAgent"
     set origText to "This is some starting text"
     set newText to cleanText origText with "Uppercase"
end tell


optionally, if you can script DEVONthink Pro to copy to the clipboard, you can use this:

tell application "textsoapAgent"

      cleanClipboard with "Uppercase"

end tell

In this case, it is assumed the script will put the text on the clipboard before hand and put it back wherever it needs to go afterwards.

Finally, if the goal of the Script is to just invoke the cleaner, you might consider a shortcut hot key.

CleanShot 2022-08-06 at 09.20.01.jpg

Hope that helps.

Reply all
Reply to author
Forward
0 new messages