473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

which application put data into clipboard

Is there a way to find out which application put data into the clipboard. I want my app to respond only when data was put into the clipboard from a specific application. The clipboard notifier code that I am using
Sep 21 '09 #1
3 2265
I figured it out after doing some more research. Here is the code that I put in the clipboard change event.


IntPtr ownerHwnd = GetClipboardOwner();

uint processId;
GetWindowThreadProcessId(ownerHwnd, out processId);
Process process = Process.GetProcessById((int)processId);
Debug.WriteLine(String.Format("Owner: {0}, processid: {1} Title: {2} Exe: {3}", ownerHwnd.ToString("X8"), processId, process.MainWindowTitle, process.MainModule.FileName));


One thing that I have noticed is that I can't always get the window title. Apps like Internet Explorer and file explorer don't return a title.
Sep 21 '09 #2
Plater
7,872 Expert 4TB
Is the application that puts data on the clipboard your own?
If so, have it add a custom datatype to the clipboard as well as the other data that you can trigger off of?
Sep 21 '09 #3
Nope, it could be any application that puts any type of data into the clipboard. My solution is back a few posts. This is how it works:

In the configuration of section of my program, I have a property that stores the application being monitored, which is the exe filename. When I get a clipboard content changed notification, I find the processid from the owner handle that last put data into the clipboard using GetClipboardOwner and then GetWindowThreadProcessId. With the processid, I can get the Process using Process.GetProcessById. From there, I can get various properties including the filename, which is compared against the one that I configured to be monitored. If they match, the clipboard data is processed.
Sep 21 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: VB User | last post by:
Earlier in VB6, the image was copied onto the clipboard from the Image Processing Program . This image would then be loaded onto the image control on the VB form using GetData() function. In...
7
by: TC | last post by:
Hello, I am familiar with obtaining source file reference material from the system clipboard using the old Win32 API. For example, copy an Excel chart onto the clipboard and goto Word. Under,...
1
by: active | last post by:
I'm trying to retrieve Locale data from the clipboard. I'm not sure if I should use Stream to MemoryStream. I tried both and the most I could obtain was 4 bytes from the clipboard. Anyone know...
2
by: yxq | last post by:
Hello I want to get Windows clipboard data size, seem to use the function "GetClipboardDataSize". Could anyone please tell how to do using vb.net? Thanks
1
by: GeorgeK | last post by:
Hello guys, I'm writing a little application and I need to copy something into the clipboard and then close the application. When I terminate the app with END or Me.Close the clipboard gets...
1
by: Robert Bravery | last post by:
Hi all, I'm using the following code to copy data from XL to the clipboard to be later usied in a datatable range = objSheet.get_Range("A22", "aa100"); range.Copy(Missing.Value).ToString();...
5
by: cgd | last post by:
hi, i want to save the MS Word data (not the Word file) to a database, so i copy the Word data to clipboard first,and then get the data to a DataObject object, and then try the code below, ...
2
by: =?Utf-8?B?dmluY2VudA==?= | last post by:
How to determine is there any data stored on the clipboard in C#? Many thanks for your replying.
8
by: ALTAFAD | last post by:
How to copy selected (s) textfield, which those selected through checkbox I like to copy in clipboard. Access textfield data when front of the textfield checkbox is checked if not checked it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.