Connecting Tech Pros Worldwide Help | Site Map

Get the selected Text from other Process

Marcus Peters
Guest
 
Posts: n/a
#1: Nov 16 '05
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


Mohamoss
Guest
 
Posts: n/a
#2: Nov 16 '05

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

Marcus Peters
Guest
 
Posts: n/a
#3: Nov 16 '05

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]


Mohamoss
Guest
 
Posts: n/a
#4: Nov 16 '05

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

Marcus Peters
Guest
 
Posts: n/a
#5: Nov 16 '05

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