How to: Imitate windows copy action

Hi,

I need to imitate windows copy action...

I have a hotkey which I registered in my background service. In my hotkey event I want to collect marked items to the clipboard using the Clipboard.SetDataObject([marked item]) .

My problem is that I dont know how to recognize/get the marked item...

Thanks,





Answer this question

How to: Imitate windows copy action

  • Nick Martyshchenko

    Hi,

    Apparently I wasnt clear enough.

    Lets say I have an internet explorer open and I initaly marked a piece of text in the open web page. I also registered a Hotkey to raise an event. I want in this event to copy the marked text to clipboard.

    The problem is that I dont have it 'in my hand' - it's not a selected text in a textbox in my app or something alike... I somehow needs to get it (the currently marked text) from the shell...

    Thanks,

  • Brian Leslie

    The clipboard class has contains, get, and set methods to manipulate the underlying data

    Example:


    If Clipboard.ContainsImage Then

    Dim MyImage As System.Drawing.Image = Clipboard.GetImage

    End If

    Clipboard.SetImage(MyImage)



     


  • HalW MSFT

    Hi again,

    For the mean time I used the 'sendkeys.sendwait' method with "^c" as parameter and that is doing the job.

    but I really wants to know the API behind 'CTRL+c'. Does anyone knows the registry entry which holds the hotkeys Or maybe its somewhere else

    Thanks,

  • tschuler77

    It is up to the application to make sure that stuff gets copied to the clipboard. The only windows API's being used are ones to set the item on the clipboard, and to windows, CTRL-C is just another key combination.

    Instead of catching the CTRL-C, why not try watching the clipboard

  • TivagVCH

    Hi Naya,

    Watching the clipboard wont help me because my intention is to take some text data (the user gives me by marking it), process it and paste it back to the place I took it from. Hence, I won't be able to know if the user marked some text and copied it to paste it later OR want to use my process ...

    That is why I want the user to use my hotkey after marking the text to be processed.

    Thanks,



  • How to: Imitate windows copy action