Tutorial / New Feature: Text Selection Did Change Trigger

Somewhat out of scope of this thread.. but being able to access the HTML from the clipboard manager as well would be awesome.

I've recently been playing with this in my own scripts, and have been getting it like this:

osascript -e 'the clipboard as «class HTML»' \
| sed -e 's/^«data HTML//' -e 's/»$//' \
| xxd -r -p \
| sed 's/\xc2\xa0/ /g' \

Also, just in general, haven't had a chance to play with it much yet, but this is looking like it might provide a nice workflow alternative to Alfred's Universal Actions that I currently make pretty heavy use of. Will be interesting to see which one ends up winning out as my go to tool for it as things progress!

(From a pace/openness of development and engagement with bugs/feedback on the forum, BTT already wins my :black_heart:)

1 Like

if you just want to get the current clipboard content HTML you can use BTT's run real java script:
//edit: sorry, this is broken currently. Will be fixed with next alpha

In v 5.106 you can do

get_clipboard_content:

Apple Script

tell application "BetterTouchTool" to get_clipboard_content format "public.html" asBase64 false

JavaScript

let html = get_clipboard_content({format: "public.html", base64: false});

get_selection

Apple Script

tell application "BetterTouchTool" to get_clipboard_content format "public.html" asBase64 false

JavaScript

let html = get_selection({format: "public.html", base64: false});

https://docs.folivora.ai/docs/1106_java_script.html

2 Likes

@Andreas_Hegenberg Something strange happened after updating to 5.105 – now, whenever I select text, it gets copied to my clipboard without me using Command-C.

I confirmed that it only happens when the BTT is running, and that the "Text Selection Did Change" automation is triggered. I haven't made any changes to the automation or floating menu since updating.

@bahphooey in which app are you seeing this? Chrome?

Seems to be happening in all apps: Brave, Stickies, even within BTT itself

could you check whether this is still the case in 5.110 (uploading will be available in 10 min)? I can't seem to reproduce it here, maybe I already fixed it in my local build.

//edit available now

Seems to have been fixed in 5.110 – thanks so much!

Hey Andreas, is there a way to Deactivate the text selection menu when I'm using Blender? I encounter a lot of issues when I use it. Additionally, since the last few versions of BTT, I have a new bug with my floating menu; it doesn’t trigger the menu when I press my key. I have to disable the group and then enable it again for my floating menu to work. and if i restart btt, i have to do it again

yes, you can edit the conditional activation group to exclude apps! I‘ll exclude Blender in the next version of the example preset

Can you give some details about your other issue? Maybe send the menu to me (andreas@folivora.ai)

ok sending u the menu now

1 Like

@Emm_Gr should be fixed in 5.113

1 Like

Thanks YOu very much :pray:t3:

This preset version fixes a few bugs, adds blender to the excluded apps and adds a "Copy as HTML" item, which copies the selection as HTML if possible. This one is set to only show while pressing CMD.

text-selection-menu16.bttpreset (357.6 KB)

BetterTouchTool v5.117 also fixes some issues related to modifier keys and disabled items.

3 Likes

wow I love this new feature. I may have to get rid of popclip

what is this for? below:

ah sorry I accidentally exported this menu. You can delete it. I‘ll upload a new preset later

1 Like

idk if you are replying to me or not. if you are thank you.

when you update the preset do you do it on the original post or the last post? I'm confused

Yep here is a fixed preset:
text-selection-menu20.bttpreset (273.3 KB)

3 Likes

This preset fixes the youtube downloader item (I accidentally broke it when I added support for rich-text):
text-selection-menu21.bttpreset (273.3 KB)

If you want to use it make sure to install yt-dlp and ffmpeg first

brew install yt-dlp
brew install ffmpeg

Tomorrow I'll finalize the documentation and then release a first stable version of this feature. Maybe it also makes sense to create a split up version of the preset where every widget/extension is in a separate file so you don't always need to import the whole preset and/or can use specific items to extend your own custom menu.

4 Likes
  1. Have gotten some freezing of Better Touchtool, and i have to force quit it. I think it has to do with me disabling some of the items of the menu? Whats right way to disable items of the menu? (Disableing the text selection menu stoped freezing Better Touchtool)

  2. And also conditional activation of items. Does that need to be implemented in the script? For example only have text manipulation show in text apps. Maybe thats something that i just should wait for you to develop?

  3. For the future it would be nice to be able to just add new buttons by downloading them like you can on popclip. But I guess its a big project. Im almost ready to ditch popclip, but the custmisation is bit too complex for my limited programing understanding. But great work so far!

  4. Where can i see the version of an installed preset?

Disabling should not cause issues. Did you get freezes while BTT preferences UI or while using the menu? It is possible that the menu could cause issues when used in BTT itself because sometimes an app scripting itself can cause weird deadlocks. I haven't seen that, but you can try disabling the menu for BTT itself.

  1. And also conditional activation of items. Does that need to be implemented in the script? For example only have text manipulation show in text apps. Maybe thats something that i just should wait for you to develop?

The following requires 5.122 due to a previous bug!! The easiest way to do this is by creating an additional conditional activation group. Here is an example CAG that is active for Text Edit, Xcode, VS Code and Sublime Text. Here is a simple example preset you can look at:

text-selection-menu-v1.bttpreset.bttpreset (313.3 KB)


Then you can add buttons that show in addition (just make sure the menu has the same identifier in every CAG):

Now if you show the menu in e.g. Text Edit it will show these two orange buttons in addition.

For the future it would be nice to be able to just add new buttons by downloading them like you can on popclip. But I guess its a big project. Im almost ready to ditch popclip, but the custmisation is bit too complex for my limited programing understanding. But great work so far!

That is already possible. I'll split up the menu into separate files tomorrow. (In general you can export any item in BTT to a file by right-clicking it)

Where can i see the version of an installed preset?

Good point. I have now added a version name to the preset.

I'll work on a thorough tutorial, also on how to quickly transform a PopClip extension to BTT.

1 Like