Note:
Before bug reporting, please make sure you have tried the latest (alpha) version of BetterTouchTool and that you have already tried to restart your system :-). If you encounter a crash, please attach a crash log from the macOS Console.app from the "User Diagnostic Reports" section.
Describe the bug
I upgraded to Ventura recently and since then this trigger has stopped working. I've confirmed that everything else is working (the key trigger is fine, the "test execute" works as it should). I inspected the console and was able to catch this error whenever key-triggering (it doesn't happen on "test execute"):
Warning: Window BetterTouchTool.HUDWindow 0x112a1fdb0 ordered front from a non-active application and may order beneath the active application's windows.
I've tried recreating and moving things around as well as restarting.
I have other JS replace scripts and they are also not working.
Device information:
- Type of Mac: M1 Pro, 14"
- macOS version: 13.4.1
- BetterTouchTool version: 4.175
It shouldn't matter (since I know it worked/s), but here is the script:
async (clipboardContentString) => {
var chars = [
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", // letters
"0123456789", // numbers
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" // either
];
return [0,0,clipboardContentString.length].map(function(len, i) {
return Array(len).fill(chars[i]).map(function(x) {
return x[Math.floor(Math.random() * x.length)];
}).join('');
}).concat().join('').split('').sort(function(){
return 0.5-Math.random();
}).join('')
}
This seems to work fine here. (It's generating some random strings, I haven't tried to understand what the code actually does)
You can ignore the warning, that is not relevant for e.g. HUDWindows because their window level is higher than default.
Maybe one note: due to the lack of better ways, the transform & replace actions use cmd+c and cmd+v to get the selected text and output the transformed text. Are you maybe using some special keyboard layout that might break the standard cmd+c+/ cmd+v? (BTT tries to figure that out but it's not easy)
Hi Andreas, thanks for the quick response.
When you say that "seems to be working fine here" do you mean the script works or that the whole functionality works in your own environment? Because I know the script works already; yes it should replace any selected text with randomly generated letters.
I don't have any presets that would interrupt the copy/paste functionality (that I know of). I run another program called ClipMenu which keeps track of copy history. Turning this off makes no difference. Also, trying the operation in different app/windows makes no difference.
One thing I just tried based on your explanation about copy/paste is to look at my clipboard history. When I run the operation, I can see that the selected string was successfully copied into my clipboard - so I know at least that is working.
Any other ideas?
In my case it's fully working. I tried assigning the script to some keyboard shortcut.
Could you check whether there are any errors logged in the safari Java Script Debugger (you need to activate the Develop menu in the Safari settings):
Maybe add a console.log() like this to your script, so you can see it is actually running:
async (clipboardContentString) => {
console.log('replacing selection with random characters');
var chars = [
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", // letters
"0123456789", // numbers
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" // either
];
return [0,0,clipboardContentString.length].map(function(len, i) {
return Array(len).fill(chars[i]).map(function(x) {
return x[Math.floor(Math.random() * x.length)];
}).join('');
}).concat().join('').split('').sort(function(){
return 0.5-Math.random();
}).join('')
}
So, I added this logging:
console.log(clipboardContentString);
and that maybe reveals something... When I test the script from within BTT, I get:
testasdasd
(the test string that I would expect to see)
But when I test the command using command keys, I get:
clipboardContentString

So it seems like something is not working right. Any idea what I should do/try next?
That is very weird (unless you have selected the text clipboardContentString). The only other way I see this happening is if you have copied clipboardContentString to your clipboard and BTT can't get the selected text due to cmd+c not working for some reason, so it doesn't update the clipboard)
Maybe copy the whole trigger configuration and paste it here (select the trigger in BTT, press cmd+c, then come back here and press cmd+v)
Are you trying this in a specific app, or does it not work in any app?
Ahaa! I figured something out... what I see in the console is just pasting out the most recent thing I copied rather than the selected text.
So for example: if I copied "abc123" and then went to the text (in any application) "testestest" and did the key combo, what would get logged would be "abc123". So that explains one thing and it possibly explains why things in general aren't working, right?
To answer your other question: there is the same behavior regardless of what app I am in.
Further, I have strong reason to believe that the CMD+C, CMD+V operations are not working as you suspected. Consider this:
async (clipboardContentString) => {
console.log(clipboardContentString.toUpperCase());
console.log(clipboardContentString);
return 'test'
}
When run on the text selection "testestest":
- doesn't make any changes; this proves that CMD+V is not working
- the console logs "abc123"; this proves that CMD+C is not working
Any idea how I can root out what might be stopping the CMD+C/V operations from working?
so far I only found special keyboard layouts like dvorak to be problematic for the cmd+c & cmd+v actions - but you are using a standard keyboard layout, correct?
Yes. And this only became an issue immediately upon upgrading to OSX Ventura.
pressing cmd+c manually on your keyboard to copy stuff still works?
yes, it does; however, I should clarify my previous statements about CMD+C not working since I know that some aspect of it is working because when I check my clipboard history, I see the selected text there (which I didn't CMD+C). So that would imply that the break in workflow is happening between getting the selected value and sending that over to the JS script.
Hey Andreas, I just updated to the latest release and I still have this issue. I've done a bunch more testing and replicated my previous experiences from the above thread. Any chance you can help me diagnose some more? I used to use the target functionality a lot for work and I could really use having it again.