get_string_variable({ variable_name: 'selected_text' }) copies the text to the clipboard


Describe the bug

Simply using get_string_variable({ variable_name: 'selected_text' }) in JavaScript copies the selected text to the clipboard.

Internally, BTT (if I'm not mistaken) copies the selected text to access it and then pastes what was previously in the clipboard back. It seems that this second part is not working well in the latest versions.

Steps to reproduce:

  1. Create an action with "Run Real Javascript" and assign this function:
    async function someJavaScriptFunction() {
     await get_string_variable({ variable_name: 'selected_text' });
    }
    
  2. Select a text and execute that action with a shortcut.
  3. Paste the text you have in the clipboard. The clipboard now contains the selected text.

Device information:

  • Type of Mac: M4
  • macOS version: Sequoia 15.1.1
  • BetterTouchTool version: 5.205 (alpha)

Any updates? Were you able to reproduce?

unfortunately I can't reproduce the issue here, the clipboard changes briefly (that's required to copy the selected text), but then BTT immediately restores the previous contents.

Have you tried with the current alpha versions, does it still occur for you?
Maybe you can use these two new actions as workaround:

Yeah, I'm using the latest alpha version (5.268).

That's strange. I can reproduce it perfectly every time I use get_string_variable({ variable_name: 'selected_text' }).

Maybe it's an option I'm using? I cannot find anything that could be related.

Yes, those work fine as a workaround. Thanks :slightly_smiling_face:

do you maybe have some other clipboard manager app running that could interfere?

Not as far as I know, I only use BTT. The only other application of the same style that I use, which is capable of modifying the text globally, is Grammarly. But I just tried closing it and BTT keeps having the same issue.