Solved

Question about the clipboard

Posted on 2004-04-30
11
214 Views
Last Modified: 2013-12-03
Is it possible to change the clipboard contents without using the windows API functions OpenClipboard() or SetClipboardData()?

I am trying to create a hook that tells me when a program has changed the clipboard contents.  This works fine for most of the programs I've tested it on, but there is 1 program that changes the clipboard contents, and my hook is not notified of it.  I am hooking the two functions mentioned above, so I am wondering if this program is changing the clipboard contents without calling those two functions somehow.
0
Comment
Question by:lwinkenb
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 10965417
Let me phrase it like this: Would you take a "no" as an answer?
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 10965512
I would if it was the correct answer.  If there's no other way to access the clipboard, then there is no other way.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 10974073
It seems to me that the easiest way to detect changes in the Clipboard would be to register yourself as a ClipboardViewer via the SetClipboardViewer API.

In what way is the "problem app" changing the clipboard... There are certain "changes" that are just reformatting of existing data that takes place when it is requested.

-- Dan
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 5

Author Comment

by:lwinkenb
ID: 10974095
Well the problem is that the program in question keeps setting itself as the clipboard owner, and it doesnt pass along the WM_DRAWCLIPBOARD messages.  

>> In what way is the "problem app" changing the clipboard... There are certain "changes" that are just reformatting of existing data that takes place when it is requested.

That is pretty much what the app does.  It reformats data on the clipboard.

I have a mistake in my original post.  Instead of hooking OpenClipboard(), I was actually hooking EmptyClipboard().  So the two functions I was hooking was EmptyClipboard(), and SetClipboardData().
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 10983053
>> It reformats data on the clipboard.

Can you describe an example?
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 10983272
Sure.

The app monitors the clipboard, and when it sees a specific thing pasted to the clipboard, it will change that text.

For instance, Let's say the following was posted to the clipboard:

Player
team
minutes
points
rebounds
Tracy McGrady
Magic
41
32
4

Now the app recognizes that text as something it's supposed to format.  What it does it put the following onto the clipboard:

Player: Tracy McGrady
Team: Orlando Magic
Minutes: 41
Points: 32
Rebounds: 4

I'm not sure exactly how it recognizes that the text is something it's supposed to format.  Maybe it just looks for text where the first line contains "Player", and the second line contains "Team".
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11022526

  Look at this article "Monitoring the Clipboard"
  http://www.innotts.co.uk/zephyr/monclip.html

  I hope you can undestand the code in Delphi
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 11022805
Please read all the comments in the thread Ivanov.  I cant monitor the clipboard that way because the application doesn't pass along the WM_DRAWCLIPBOARD messages.
0
 
LVL 86

Expert Comment

by:jkr
ID: 11175351
Hmm, I thought you'd take a 'no' as an answer? :o)
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 11175617
hehe, I would - but no one gave me no as an answer.  I thought Dan might of had an idea which is why I kept this question open.  I guess since you insinuated that the answer to my question was 'no', then you deserve the points.  I was looking for something a little more concrete though :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question