Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 16th, 2005, 01:10 PM
Marcus Peters
Guest
 
Posts: n/a
Default Get the selected Text from other Process

Hi folks,

I need to copy the selected text in any other application to the clipborad.

I played around with several ways which did not work:

Win API: Send a Message with WM_COPY --> Worked only with TextBoxes,
ComboBoxes and so on, There are several posts for doing so.
But way to copy from for example from IE.

Win API: Send some Messages wich should simulate pressing the Ctrl-C keys
(SendMessage and keybd_event)
Any Ideas ?



Regards,

Marcus


  #2  
Old November 16th, 2005, 01:13 PM
Mohamoss
Guest
 
Posts: n/a
Default RE: Get the selected Text from other Process

Hi Marcus
check out this link

http://www.realvnc.com/pipermail/vnc...ry/005118.html

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

  #3  
Old November 16th, 2005, 01:13 PM
Marcus Peters
Guest
 
Posts: n/a
Default Re: Get the selected Text from other Process

Hi Mohamed,

thanks for your help. But that was not what I was looking for.
I managed it by my self now.

My Question was to Send Ctrl-C to a window of any other process. This is to
tell
windows I wanna copy the selected text of the particular window. I need to
send Ctrl-C
cause the window may contains control other than Textbox or ComboBox (wich
accept the WM_COPY Message).

But as I told you I made it. If you need help doing the same let me now I
will tell you then.

Best regards,

Marcus




"Mohamoss" <mohamed.mossad@egdsc.microsoft.com> wrote in message
news:jwK9qnEsEHA.3356@cpmsftngxa06.phx.gbl...[color=blue]
> Hi Marcus
> check out this link
>
> http://www.realvnc.com/pipermail/vnc...ry/005118.html
>
> Mohamed Mahfouz
> MEA Developer Support Center
> ITworx on behalf of Microsoft EMEA GTSC
>[/color]


  #4  
Old November 16th, 2005, 01:19 PM
Mohamoss
Guest
 
Posts: n/a
Default Re: Get the selected Text from other Process

HI Marcus
thaks for the reply , yes sure please share that so any one would make use
of it while encountraing the same situation
thanks again
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

  #5  
Old November 16th, 2005, 01:23 PM
Marcus Peters
Guest
 
Posts: n/a
Default Re: Get the selected Text from other Process

Hi Mohammed,

here is the code

....
[DllImport("User32.dll")] private static extern bool

SetForegroundWindow(IntPtr hWnd);

[DllImport("user32.dll", CharSet=CharSet.Auto)]

static public extern IntPtr GetForegroundWindow();

[DllImport("user32.dll")]

static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,

uint dwExtraInfo);



.....

private void SendCtrlC(IntPtr hWnd)

{

uint KEYEVENTF_KEYUP = 2;

byte VK_CONTROL = 0x11;


SetForegroundWindow(hWnd);


keybd_event(VK_CONTROL,0,0,0);

keybd_event (0x43, 0, 0, 0 ); //Send the C key (43 is "C")

keybd_event (0x43, 0, KEYEVENTF_KEYUP, 0);

keybd_event (VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);// 'Left Control Up



}


Regards,

Marcus



"Mohamoss" <mohamed.mossad@egdsc.microsoft.com> wrote in message
news:eTZjUBSsEHA.3252@cpmsftngxa10.phx.gbl...[color=blue]
> HI Marcus
> thaks for the reply , yes sure please share that so any one would make use
> of it while encountraing the same situation
> thanks again
> Mohamed Mahfouz
> MEA Developer Support Center
> ITworx on behalf of Microsoft EMEA GTSC
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.