Detecting selected (hightlighted) text in a file

hi,

is there any way to detect selected text from within a text file? for example, if i have a txt file and selected a string (a subset string) from the text, can i save that in a variable?

thanks in advance.
01

Hi, since you found how to do it, I’ll post here the link to your other thread :slight_smile:

hi hamoid,

if i wanted to do this in oF, i wouldn’t be able to use the java library, correct? is there a way to do it in c++?

thanks.
01

thanks.

You’re right that the java library won’t work. There’s probably a way to do anything in C++ :slight_smile:

This is totally not OF related, but in Windows you can use AutoHotKey to trigger a CTRL+C and then save the selected text to a file.

the cntl-c idea could work actually. but, if i used that to detect the text, is it possible to copy the contents of the clipboard to a variable (without saving to a new text file)?

From OF you can get the clipboard text:

https://openframeworks.cc/documentation/application/ofAppRunner/#show_ofGetClipboardString

thank you!

01