I been wondering how to make my vb6 form run in sync with the windows clipboard, so if someone copies something off of a web page for example, it will automatically insert into my form if I have it up.
Printable View
I been wondering how to make my vb6 form run in sync with the windows clipboard, so if someone copies something off of a web page for example, it will automatically insert into my form if I have it up.
Make a timer which will periodically (like every 200 miliseconds) read the clipboard
That would work great, but I also wanted to be able to keep up everything that is copied, instead of acting like the windows clipboard.
So if I copied 5 different things at 5 different times, they all show in order in a textbox. Get the concept? (I hope, it's confusing me :)
Make on textbox that acts as the main storage, and make one that will act as a buffer. Like txtData and txtBuffer, and make the timer read the clipboard into the txtBuffer, and then put the code:
txtData.Text = txtData.Text & vbcrlf & txtBuffer.Text
in the txtBuffer_Change sub
that way, only if the data is different it will be copied into the storage textbox
Actually, right after I posted my second post, I thought of that. So I tried it. It works out great! But of course, I ran into another problem now. It only works if the text that I copy changes. But in some cases, the text that I'll be copying will be the same =/ I can copy the statement "You are teh winnah" and it will put it in the storage textbox. Then I copy it again, and it does nothing (obviously because there is no change). Thanks for all your help, it is much appreciated.Quote:
Originally posted by baja_yu
Make on textbox that acts as the main storage, and make one that will act as a buffer. Like txtData and txtBuffer, and make the timer read the clipboard into the txtBuffer, and then put the code:
txtData.Text = txtData.Text & vbcrlf & txtBuffer.Text
in the txtBuffer_Change sub
that way, only if the data is different it will be copied into the storage textbox
That is ture, but if you already have it once, why would you need it again?
just add a counter to the front of it, and then paste it
This
2 This
3 2 This
or check to see if they are the same, and then add the counter to the saved value before pasting it, and the count will be different
This
2 This
3 This
That
One way is to clear the clipboard in the timer (after you get its data) but then you will loose functionality of the clipboard (it will always get emptied...
So then I must find another method of going about trying to do what I want. Trial and error I suppose, thanks everyone :)
Well, I'm happy to say that I figured it out. The timer that adds the buffer box to the storage box is the key. After it added it's information, I had it set the clipboard to "" as well as the buffer box. Then in the bufferbox_change statement I threw in an If Then statement that said if bufferbox = "" then basicly do nothing. It's working 100% right now, thanks for all your much needed help :)
That is exactly what I said in my last post. But arent you loosing functionality of the clipboard that way? If the user copies anything you app grabs it and empties the clipboard (withing 200-300 ms, what ever you set the timer to) so when user tries to paste it, the clipboard will be empty.