Solved

Question about the clipboard

Posted on 2004-04-30
11
211 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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