Jump to content

How to define an paste event from the clipboard?


AndreyS
 Share

Recommended Posts

Hello to you, dear developers!
Could you please tell me if there is an easy way to determine if the information was pasted from the clipboard?
Without any variation of the insertion via Ctrl+V, or through the context menu.

I revised the Help and many forum topics, but found nothing suitable.

Can there be any WinAPI system events that determine this event?

Link to comment
Share on other sites

  • Moderators

You can compare the information with what is on the clipboard with ClipGet(), like so:

#include <MsgBoxConstants.au3>

$sText = InputBox("Clipboard Test", "Please enter your text")
MsgBox($MB_OK, "Clipboard Test", "Your text " & ($sText = ClipGet() ? "matched" : "did not match") & " what was on the clipboard")

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thank you for your participation JLogan3o13!
No, this method does not fit. First, there should be no input of the user. Secondly, this method shows whether the information has changed in the buffer or not. And I need to count the number of extractions of information from the clipboard, i.e. how many times the user pressed the insertion key combination or inserted through the context menu.

Link to comment
Share on other sites

  • Moderators
2 hours ago, AndreyS said:

First, there should be no input of the user.

Think about how this part fits with:

14 hours ago, AndreyS said:

Could you please tell me if there is an easy way to determine if the information was pasted from the clipboard?

So your latest comment falls under the category of - should have included that information in the first place. How about giving us a more detailed idea of just what you're trying to do rather than us guessing? Help us help you ;)

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

You probably did not quite understand what I need. Or I have poorly explained, because I do not know much English.

I'll try to explain again. I need to keep track of how many times I retrieved information from the clipboard, regardless of the way it is extracted, and regardless of the program I'm working in.

Edited by AndreyS
Link to comment
Share on other sites

So, you want to globally hook into windows for all paste events.

You can start by looking for WM_PASTE, but I see the paste process is not consistent between all windows applications e.g. Excel does not use WM_PASTE. I saw quite a few posts online of people wanting to do this and none of them seemed to be having much fun.

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Link to comment
Share on other sites

Yes SlackerAl, you correctly understood me!
Yes, I saw different solutions including those based on WM_PASTE. But I do not see that they cover all the methods of insertion.
But there must be some solution. Yet programs use the same buffer and the same information from it.
I'm not talking about copying and pasting graphics, files. At least just counting the insertion of textual information.

Can there be any variable or event that occurs when accessing the buffer and extracting information from it?

Edited by AndreyS
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...