I am trying to make a tool in C++ that interacts with the OS functions, but I’ve never did anything similar before, so I don’t even have a clue on where to search for an answer.
Here’s an overview example of what I would like to make :
Let’s say I have a number of text files stored in a folder. Every file has some text in it and a password (just string, no encryptions). What I want to do, is enter a key-word (eg “1”, or “2”, or whatever the key-word is) and then a password will be selected amongst the files. Now, I know how to do all this “simple” stuff, my problem comes next :
Once I find the password – let’s say the password will be stored in a String psw variable – I want to copy psw string into the “buffer” (or whatever that is) that my OS (let’s say Windows) uses for the function “copy” (Ctrl + C). This resulting in : the next time I hit Ctrl+V, psw will be pasted.
Example of use :
A user runs the .exe and a window opens. He then enters a key-word and a password is selected and added to the “buffer” that handles the “copy” function. The programm may terminate at this state, or wait for another password (we don’t care about it anymore). Now, let’s say the user creates a text file, hits Ctrl + V and a password is pasted into the text file, without any other interactions from the user-side inbetween.
And here’s are my questions :
Is this even possible or should I give up on the idea ?
If yes, I would appreciate any help, tutorial, or some pattern on where to search for this.
Thanks in advance !
This is more of a “Windows” answer than it is a “C++” answer, but the code below will work in C or C++.
On windows, you pragmatically “paste”strings into the clipboard via the Win32 API.