get data from text file and send to text field

I need to make something like copy and paste

Having file, get string from here, need to send (paste) it to the field where cursor now at.

Please advise
Last edited on
What field? What library/framework are you using with C++ for gui?
Im using Qt Editor, but I think it does not matter.

any field where you can print, I'm making AutoHotKey analog, when I press lets say ctrl + T, I want to send some text from file to field (webrowser text field, command line text field, or word document text field)
Im using Qt Editor, but I think it does not matter.

It does matter. If it's "your" application that you control, then you can simply do something like this, for example:

QTextEdit *myTextEdit = /* .. */
QString text = myTextEdit->textCursor().selectedText();

...assuming your are writing a Qt-based application with a QTextEdit widget:

(There are similar ways with other widgets, such as a QLineEdit)

If you want to "exfiltrate" the text from a third-party application, things will be more difficult!

You can install a clipboard listener, so that your application will be informed, via WM_CLIPBOARDUPDATE, on every clipboard change:

You can then get the clipboard contents, after each change, via OpenClipboard() + GetClipboardData() + CloseClipboard().

But there is no easy way to "force" a third-party application to copy the desired text to the clipboard... 🤔
Last edited on
Registered users can post here. Sign in or register to post.