How to paste custom (variable) text using webView?

How do you paste custom text from a variable in js?

Using the copy to json function for paste text, the string is turned into a string of characters (some kind of encoding?), "Why" becomes: "BAtzdHJlYW10eXBlZIHoA4QBQISEhA1OU1RleHRTdG9yYWdlAISEGU5TTXV0YW..."

Replacing this string with a normal text string results in nothing being pasted using

callBTT('trigger_action', json: {..., 
  "BTTAdditionalActionData": {
    "BTTActionTextToPaste": "Why"
  }
})

Is there a better way to paste text to another application than using this method? If not, how do you encode text to this format?

Ah this is indeed a bit complicated because the BTTActionTextToPaste transforms its content to richtext and then base64 encodes it (so it can also paste bold/with colors etc.)

There is an undocumented way how you can paste plain text though:

(async ()=> {

BTTActions.pasteString('test');
returnToBTT('');

})()

You can also use the BTTActions.pasteString('test'); directly in a BTT webview

1 Like

Thanks Andreas! Amazing response time as always

Imprint | Privacy Policy