🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages Started by Emmanuel Tue, 09 Oct 2007 04:12
How to paste the text in the clip board in to other application?
#1208
Author: Emmanuel
Date: Tue, 09 Oct 2007 04:12
16 lines
1322 bytes
Dear All,

I am try to paste some text from Clipboard to other Apllication, but I find 
fail to do it by me code.

void __fastcall Paste(AnsiString C)
{Clipboard()->AsText=C;
 keybd_event(VK_CONTROL, 0, 0,0);
 keybd_event('v', 0, 0,0);
 keybd_event('v', 0, KEYEVENTF_KEYUP,0);
 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP,0);
}

Would anybody teach me?

Thank you 
Re: How to paste the text in the clip board in to other application?
#1210
Author: Pete Fraser
Date: Tue, 09 Oct 2007 08:16
23 lines
1619 bytes
You have to find the handle of the other application and 
send the CTRL+V message there.
HTH Pete

"Emmanuel" <emmanuel@erphk.com> wrote in message 
news:470aff65@newsgroups.borland.com...
> Dear All,
>
> I am try to paste some text from Clipboard to other 
> Apllication, but I find fail to do it by me code.
>
> void __fastcall Paste(AnsiString C)
> {Clipboard()->AsText=C;
> keybd_event(VK_CONTROL, 0, 0,0);
> keybd_event('v', 0, 0,0);
> keybd_event('v', 0, KEYEVENTF_KEYUP,0);
> keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP,0);
> }
>
> Would anybody teach me?
>
> Thank you
> 
Re: How to paste the text in the clip board in to other application?
#1215
Author: Vladimir Stefanovic
Date: Tue, 09 Oct 2007 11:06
26 lines
1578 bytes
> Would anybody teach me?

#include <ClipBrd.hpp>
// ...
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   HANDLE notepad = FindWindow( "Notepad", 0 );
   if ( notepad )
   {
      Clipboard()->AsText = "Test";
      BringWindowToTop( notepad );
      keybd_event( VK_CONTROL, 0, 0, 0 );
      keybd_event( 'V', 0, 0, 0 );
      keybd_event( 'V', 0, KEYEVENTF_KEYUP, 0 );
      keybd_event( VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 );
   }
   else
   {
      ShowMessage( "Please, open notepad first." );
   }
}


-- 
Best Regards,
Vladimir Stefanovic
Re: How to paste the text in the clip board in to other application?
#1163
Author: Emmanuel
Date: Thu, 18 Oct 2007 17:41
31 lines
1613 bytes
Fail
"Vladimir Stefanovic" <antivari@sbb.co.yu> д���ʼ�
news:470b5fa8@newsgroups.borland.com...
> > Would anybody teach me?
>
> #include <ClipBrd.hpp>
> // ...
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
>    HANDLE notepad = FindWindow( "Notepad", 0 );
>    if ( notepad )
>    {
>       Clipboard()->AsText = "Test";
>       BringWindowToTop( notepad );
>       keybd_event( VK_CONTROL, 0, 0, 0 );
>       keybd_event( 'V', 0, 0, 0 );
>       keybd_event( 'V', 0, KEYEVENTF_KEYUP, 0 );
>       keybd_event( VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 );
>    }
>    else
>    {
>       ShowMessage( "Please, open notepad first." );
>    }
> }
>
>
> -- 
> Best Regards,
> Vladimir Stefanovic
>
>
Re: How to paste the text in the clip board in to other application?
#1165
Author: Vladimir Stefanovic
Date: Thu, 18 Oct 2007 17:50
20 lines
1376 bytes
> Fail

Works fine for me, and I've tested it right now again.

However, one modification could be of useful.
Instead of:
      BringWindowToTop( notepad );
...it's better:
      if ( IsIconic( notepad ) )
      {
         ShowWindow( notepad, SW_RESTORE );
      }
      SetForegroundWindow( notepad );

Because of potential minimized state of Notepad.


-- 
Best Regards,
Vladimir Stefanovic 
Re: How to paste the text in the clip board in to other application?
#1177
Author: Emmanuel
Date: Fri, 19 Oct 2007 03:33
31 lines
1742 bytes
Success now thank
"Vladimir Stefanovic" <antivari@sbb.co.yu> д���ʼ�
news:470b5fa8@newsgroups.borland.com...
> > Would anybody teach me?
>
> #include <ClipBrd.hpp>
> // ...
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
>    HANDLE notepad = FindWindow( "Notepad", 0 );
>    if ( notepad )
>    {
>       Clipboard()->AsText = "Test";
>       BringWindowToTop( notepad );
>       keybd_event( VK_CONTROL, 0, 0, 0 );
>       keybd_event( 'V', 0, 0, 0 );
>       keybd_event( 'V', 0, KEYEVENTF_KEYUP, 0 );
>       keybd_event( VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 );
>    }
>    else
>    {
>       ShowMessage( "Please, open notepad first." );
>    }
> }
>
>
> -- 
> Best Regards,
> Vladimir Stefanovic
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads