I would look for a "after copy to clipboard hook" and handle that because the contents from Word (or any other application) should be in the clipboard. When you hook the "control-c", it'll be really hit and miss as you could get the event before or after the app you intend getting the data from. By creating your own "control-shift-c" hook, you'd need to know about the application that has focus as Noon mentioned and that means extra processing.

Just my logical analysis - I haven't done this sort of stuff.

On 15/01/2011 4:47 PM, Noon Silk wrote:
On Sat, Jan 15, 2011 at 4:30 PM, Winston Pang<[email protected]>  wrote:
Hey,

Thanks for your reply, yep looks like the solution I found online
isn't doing it, I'll try and add it in.

But my main question really is, how do I make all applications
initiate a Copy with my system wide key hook?
Ah, right, I understand.


So when you're in word, you do Ctrl + Shift + C, and it will copy the
selected text and then my application will receive this hot key
message and I can read the clipboard.
Just looking into this a bit, it seems to me (and I could definitely
be wrong) that the keyboard hook you install won't tell you which
application the event was sent to. So, you'll need to guess based on
which one has focus, I suppose, when your hook event is hit. This
doesn't seem "ideal" to me, and maybe I'm wrong.

Assuming that is the case, though, (and even if it wasn't; i.e. even
if you got a handle to the app); you'll need to probably just do a
Win32 SendMessage, perhaps, say, of WM_COPY[1]. But, this may not work
universally. Maybe there is a universal way to send "copy" (other then
simulating control-c, which is obviously strictly "bad"), meski may
know but I don't :P

So, I have no idea what you're trying to do in general, but perhaps it
would be more "stable" if you just hooked into the current control-c
event chain. However, I don't know what order that chain is executed
in (i.e. you may be first, and nothing is in there yet because the
Word app, or whatever, has not copied the text yet), so even that may
be problematic.

Sorry I don't have any real advice here. I did stumble across this,
which may be of interest (or you've maybe already seen it):
  <http://msdn.microsoft.com/en-au/magazine/cc188966.aspx#S4>

I'd be interested to know how you solve this.


Thanks again for your help and everyone else.

--Winston

Reply via email to