I love KM8, but it has broken one of my major workflows: Posting of ReleaseNotes with my macro uploads.
In virtually every Macro I write, I have a Comment Action at the top, which contains my ReleaseNotes for that Macro. Prior to KM8, I could read the plain text of the Comment Action in a script, and then paste into a KM Forum topic where I am upload my macro.
KM8: How Can I get Plain Text from a Comment Action?
Now the Comment Action uses Rich Text, which is available in an encoded format in the XML of the Action. But I have been unsuccessful in converting that encoded rich text into plain text.
@peternlewis, may I request that you provide us with a scripting command that:
- Returns plain text for any selected “
<styled text>
” element in the XML. - Return rich text as plain text (like HTML) that can be edited.
- Sets/Updates the Action from a revised rich text string.
As you know from our discussion in KM8: XML of Display Text in Window Does Not Update by Script, this is not something that is easly converted (decoded, encoded) using AppleScript. So any help you can give us would be greatly appreciated.
If there is an ASObjC or Bash script that will do the job now, I’m fine with that. My problem is that I don’t know enough about either to write such scripts.
Here is an example XML from a KM8 Comment Action:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ActionColor</key>
<string>Green</string>
<key>ActionName</key>
<string>~~~ ReleaseNotes for VER: 1.0 DATE ~~~</string>
<key>IsDisclosed</key>
<false/>
<key>MacroActionType</key>
<string>Comment</string>
<key>StyledText</key>
<data>
cnRmZAAAAAADAAAAAgAAAAcAAABUWFQucnRmAQAAAC65AgAAKwAAAAEAAACxAgAAe1xy
dGYxXGFuc2lcYW5zaWNwZzEyNTJcY29jb2FydGYxNDA0XGNvY29hc3VicnRmNDcwCntc
Zm9udHRibFxmMFxmbmlsXGZjaGFyc2V0MCBWZXJkYW5hO30Ke1xjb2xvcnRibDtccmVk
MjU1XGdyZWVuMjU1XGJsdWUyNTU7fQpccGFyZFx0eDU2MFx0eDExMjBcdHgxNjgwXHR4
MjI0MFx0eDI4MDBcdHgzMzYwXHR4MzkyMFx0eDQ0ODBcdHg1MDQwXHR4NTYwMFx0eDYx
NjBcdHg2NzIwXHBhcmRpcm5hdHVyYWxccGFydGlnaHRlbmZhY3RvcjAKClxmMFxmczI4
IFxjZjAgQXV0aG9yLkBKTWljaGFlbFRYXApcCioqUFVSUE9TRToqKlwKXAoqICoqVEJE
KipcClwKKipSRVFVSVJFUzoqKlwKXAoxLiAqKktNIDguMC4yKyoqXAogICogQnV0IGl0
IGNhbiBiZSB3cml0dGVuIGluIEtNIDcuMy4xK1wKICAqIEl0IGlzIEtNOCBzcGVjaWZp
YyBqdXN0IGJlY2F1c2Ugc29tZSBvZiB0aGUgQWN0aW9ucyBoYXZlIGNoYW5nZWQgdG8g
bWFrZSB0aGluZ3Mgc2ltcGxlciwgYnV0IGVxdWl2YWxlbnQgQWN0aW9ucyBhcmUgYXZh
aWxhYmxlIGluIEtNIDcuMy4xLlwKLlwKMi4gKiptYWNPUyAxMC4xMS42IChFbCBDYXBp
dGFuKSoqXAogICogS00gOCBSZXF1aXJlcyBZb3NlbWl0ZSBvciBsYXRlciwgc28gdGhp
cyBtYWNybyB3aWxsIHByb2JhYmx5IHJ1biBvbiBZb3NlbWl0ZSwgYnV0IEkgbWFrZSBu
byBndWFyYW50ZWVzLiAgOndpbms6IH0BAAAAIwAAAAEAAAAHAAAAVFhULnJ0ZhAAAAAG
mtJZtgEAAAAAAAAAAAAA
</data>
<key>Title</key>
<string></string>
</dict>
</plist>
The plain text looks like this:
Author.@JMichaelTX
**PURPOSE:**
* **TBD**
**REQUIRES:**
1. **KM 8.0.2+**
* But it can be written in KM 7.3.1+
* It is KM8 specific just because some of the Actions have changed to make things simpler, but equivalent Actions are available in KM 7.3.1.
.
2. **macOS 10.11.6 (El Capitan)**
* KM 8 Requires Yosemite or later, so this macro will probably run on Yosemite, but I make no guarantees. :wink:
This is just a brief example of my normal ReleaseNotes.
Example Script to Get XML of First Action of a Selected Macro
tell application "Keyboard Maestro"
set oMacro to item 1 of (get selected macros)
set actionList to actions in oMacro
set oAction to item 1 in actionList
tell oAction
set actXML to xml
end tell -- oAction
end tell -- KM
set the clipboard to actXML
return actXML