Emulate Ctrl+C (Copy to Clipboard) in a Global MouseUp Event
Here is what I want to happen at a high level: I am in any program in Windows (global) and when there is a MouseUp event, I want what is highlighted to go into the Windows clipboard (start -> Run -> clipbrd). So for example, I am in Notepad and I type “Hello World??, then I highlight the text with the mouse and on the MouseUp, the text is copied to the Windows clipboard.
On top of the keyboard emulated ctrl+c (copy to clipboard) in the global MouseUp event, I need to be able to inject my own code into the global MouseUp event below the ctrl+c, so this can’t be locked up code if you know what I mean. I need to know how to access the MouseUp event in laymans terms.
I am using Visual Studio 2008, I am programming in VB.NET, so if this is written in another language, you will need to give me the exact instructions needed to call it from VB.NET on VS 2008.
## Deliverables
What I have tried so far:
Essentially, I need to be able to inject my own code into a global MouseUp event. The first thing I want to execute in this global MouseUp event is a Keyboard emulated Ctrl+C (copy to clipboard). I have tried to do this, but have failed and can’t get it. I have been using the global Mouse Hook C# code from here:
<[login to view URL]>
and calling it in VB.NET using:
If [login to view URL] Then
AddHandler [login to view URL], AddressOf HookManager_MouseUp
Else
RemoveHandler [login to view URL], AddressOf HookManager_MouseUp
End If
Sub HookManager_MouseUp(ByVal sender as object, ByVal e as MouseEventArgs)
[login to view URL](“^C??)
End Sub
As you can see, in the MouseUp event, I am trying to use [login to view URL](“^C??) to send the Ctrl+C command. This is unfortunately not working and where I need help. SendKeys seems to work on it’s own, but not in this global mouse hook.
If it helps, I have also found VB.NET global mouse code in the following places, but I haven’t gotten them working yet:
<[login to view URL]>
<[login to view URL]>
<[login to view URL]>