Hi! First post here after using BTT for over a decade now, so I'm sorry if I'm duplicating a question that I wasn't able to find during a search or don't provide the correct information. Basically:
I have a keyboard shortcut which copies some text to the clipboard; I use BTT to link a gesture to this keyboard shortcut. For this particular text, I always want to wrap it in double quotes, so I tried adding a "Transform Clipboard Contents with Java Script" action after the keyboard shortcut action.
I don't really know any java, but figured that the following would work:
and indeed, when fed the example text, Test Execute does return "text" as desired. However, whenever I actually try to use this trigger, it only does the first action (running the keyboard shortcut which copies this text to the clipboard) and does not add the quotation marks. I had wondered if perhaps it was a permissions issue, but I doubt that this could be the case because I have another trigger which takes a screenshot and copies it to the clipboard. (Restarting the app did not fix this.)
I'm on a 2024 MBP runing Sequoia 15.2. Any insights as to how I might fix this? Thanks!
Right—the "gesture" here is just a three-finger click, which corresponds the keyboard shortcut you see in the image. That keyboard shortcut (successfully!) copies a file path without the single quotation marks to the clipboard (this is a quick action which I've bound to that keyboard shortcut).
you might need to add a minimal delay (0.1s) between the cmd+c and transformer. Alternatively - if you are on the latest alpha, you can add the "Wait For Clipboard Content Change" action inbetween
BTT sends cmd+c immediately however it doesn't know when the clipboard has actually changed, this can take a few ms
I forgot to mention that I had tried that as well—I believe I even tried a 500ms delay. I'll try again tomorrow when I'm back at my work computer, and try the alpha build if that doesn't work!
Adding a delay (async or not, from .1s to .5s) didn't fix it. Updating to alpha didn't fix it on its own (just as a test), but the new "Wait for Clipboard Content Change" did fix it. Thanks Andreas! (and thanks so much for the app—I recommend it to every mac user I know!)