"Save selected text to variable selected_text" copies clipboard content instead of selection or does not work at all

Hi, Brand new BTT user here.

The "Save selected text to variable selected_text" action behaves strangely:

Instead of copying the selected text of the currently active app, it will copy the contents of the clipboard.

Additionally, the copying of the clipboard works only once and only right after BTT has been (re-) started. Subsequent changes of the clipboard content (copying other text) and/or later invocation of the action will not change the value of the selected_text variable (it will retain the value from the first "successful" execution).

This happens consistently with the latest stable version and the latest alpha version of BTT (4.181 (2400)).

I do not know if this used to work in prior versions because I only installed BTT yesterday and currently use it in trial mode. However, from discussions in the forum related to the topic I conclude that this used to work (or still works for other users).

I am using BTT on an M1 MacBook Pro 14" from 2021. OS is Ventura 13.5 (22G74).

do you use any special keyboard layout? BTT copies selected text using the keyboard command cmd+c - which might fail with some special layouts

Thanks for the quick reply.

I have a US American keyboard, which I use with the EurKEY layout (I am German but prefer the US layout for programming). The OS primary language is set to German.

This shouldn't be a problem since cmd+c is still the shortcut for copying in this configuration.

I have PopClip and Copy 'Em installed but disabled them for checking if they could be the culprit because they also interfere with the clipboard - unfortunately no success.

could you check whether it works if you enable the standard layout? the key to keycode look up mechanism on macOS is complicated- maybe something fails for some reason.
If it’s the layout I probably have a solution.

I just tried both the US and the German standard layout - same issue :frowning:

what kind of trigger are you using to execute the save selected text to variable action?

(I just checked to make sure it’s not an issue with the latest macOS update, but it’s still working fine here)

I am using Single Finger FORCE Click (temporarily changed it to 1 Finger Tap Top Left for testing)

I just created a new blank user account with no login items, so no stuff running in the background. Language set to English, keyboard layout set to U.S. - same issue :frowning:

Some progress: After I deleted all support files (every folder or file under ~/Library whose name contained "bettertouchtool") and restarted BTT, the action still only copies the content of the clipboard, but now it registers changes of the clipboard content, and the value of selected_text will be updated accordingly.

I do not know if this might be related but in fact I did use BTT a couple of years ago, then switched to Better Snap Tool, since back then the window snapping feature was the only reason why I had BTT. I had bought a license for BTT back then and the old support files where still lying around in my ~/Library folder (and the trial nag screen also stated that there is a license which has expired).

Unfortunately, the main issue remains (selected_text is set to clipboard content instead of selected text).

Breaking news regarding this issue: The culprit is apparently not the "Save selected text to variable selected_text" action but the Floating WebView (or the combination of both).

Today I revisited the issue and found this forum post (up until now I thought the Floating WebView was the only action that can access the content of the selected_text variable).

So I tested it with the example javascript snippet that runs a shell script which calls the say command. This works just fine.

So there must be something wrong going on during the transfer of the variable content to the WebView action (maybe a caching problem or something?).

Or maybe I did something wrong? This is what my WebView looks like (I adapted it from the example from this forum):

<html>
<script>
async function BTTInitialize() {
  let selectedText = await callBTT('get_string_variable', {variable_name:'selected_text'})
  var span = document.getElementById("content");
  span.textContent = selectedText;
}
</script>
<body>
<div  style="with:100%; height:100%; display:flex; align-items:center;align-content:center; justify-content:center; background-color:white">
<span id="content" style="font: bold 24px Helvetica">...</span>
</div>
</body>
</html>

I have same problem. I have Floating WebView with similar javascript. It worked as expected few BTT versions ago (can't say how much).
At some stage it stopped, and instead of getting selected_text, it started sound "beep" like there is an error.
Today I got to troubleshooting, and found that selected_text will appears to take from clipboard. That is if do command-C , it works, if I only select, it still takes from clipboard.

1 Like