views:

143

answers:

4

hi .. iam trying to use the code posted here http://stackoverflow.com/questions/621577/clipboard-event-c

it does work really great, but while testing, i found out that when copying from some application as example firefox, you will get the event running twice, so if you are saving the copied text to a textfile, or writing them to a textbox in the application, the text copied from firefox will appear twice ?

anybody can help me with this problem ? thanks a lot

+2  A: 

Store the last input, and if the new input is the same as the last, discard ?

Sdry
-1 for ugly work-around. There should only be one event. Ok, deleted the -1, as that just seemed too mean. I concede that this is sometimes useful/necessary.
Chris Thornton
As It is only happening with some applications, and the origine of the events is not under his control, why is this approach bad ?I don't think it is bad practise to verify a change in state before executing logic.
Sdry
@Sdry, it's impossible to examine the clipboard contents without altering the state of the clipboard. You can't examine it without opening it, and that's going to have unintended consequences. You can collide with other apps (likely whatever is double-copying in the first place) and you can trigger delayed rendering requests.
Chris Thornton
A: 

Try it on a "bare" system to ensure that you aren't getting an "echo" somewhere. There should only be one notification. However, if soemthing else alters the clipboard during the event, you can get two. For example, a clipboard-driven text scrubber.

You can also get multiple events if the app doing the copying does it wrong. Such as when apps open/close the clipboard for each data format (they should not, this is a bug if they do). Try copying from plain old Notepad and see if you "hear" the event twice or not.

Chris Thornton
A: 

hallo ... sorry for not answering for the last days: i did tried the Ctrl+C option, it is the same.. also i tried it on oanother system with fresh installed windows and firefox on it, and it is still the same ... on notepad it is working well, it just get copied once, also on IE, chrome and and and also working normal ..only on firefox till now ...

just a question ,: how would i check if the DATA is the same as the last clip? how can i compare the data in the clipboard with another Data saved before? i can do it with text, but formatted text, images, and so on, how can i compare them? thanks in advance

lena2211
You cannot compare to the last clip without pasting the data into yourself, twice. Doing that will alter what you're trying to measure.
Chris Thornton
A: 

Do you have any plug-ins runnign within FF? It sounds like you do. Try it on a "bare" system with brand-new FF and nothing else.

Chris Thornton