Connecting Tech Pros Worldwide Help | Site Map

Get the selected Text from other Process

  #1  
Old November 16th, 2005, 01:10 PM
Marcus Peters
Guest
 
Posts: n/a
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

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

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

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

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]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
get the text from a window in an external program beethoven answers 5 October 16th, 2008 09:44 PM
DropDownList with multiple selected items error Aaron Prohaska answers 1 November 18th, 2005 01:04 AM
Pass variable selected from drop down option field to text fields Dan answers 4 July 23rd, 2005 04:37 PM
copying window text....please help! this language is insane. chris kramer answers 3 July 22nd, 2005 06:42 AM