It’s not the same if you launch a script with osascript (which is what KM uses) or with Script Editor. Apparently Script Editor is more tolerant.
But this is not related to the Pro Tools thingy. Not every app responds to the accessibility attributes like "AXDocument". See the topic which you have linked to.