dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: copy select item by vb6

  1. #1
    Join Date
    Dec 2007
    Posts
    49

    copy select item by vb6

    Hi all

    I have a Question

    How i can Select And Copy Text from any programe to My vb6 project??

    i need code to select and copy all text from any programe on top in the screen to Text1.text



    Thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    if I understand correctly, you want to select the text in any program, copy it and paste in some part of your code.

    It is not that easy, you need to find the handle of the window that has the text. There is no native VB code to do that, you have to use Windows API like GetForegroundWindow, EnumWindows, FindWindow, and after you find the right one use the GetWindowText to get its text. It is really messy and not always you get either the right window or the right text, and as soon as the original application changes its interface, your code does not work anymore.

    This is the link of the MSDN reference page for the Windows functions:
    http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Code:
      If TypeOf Screen.ActiveControl Is TextBox Then
        Screen.ActiveControl.SelText = Clipboard.GetText()
      End If
    If you are just trying to get the text off the clipboard then the code above should work for any text box. You would put this code within the event handler for your 'Paste' option in your programs Edit Menu. If you are already in a text box and you are not using a menu command you can simply type Ctrl-P, and that should do it, no code nessasary.

    But remember that every time you start up the VB6 IDE it erases the clipboard. So when testing in the VB6 IDE you will need to do the copy from the other application, after you start the VB6 IDE.

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Ron, ActiveControl returns the control of the same application that would have the focus if the form/application were active, it does not work for other applications.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Similar Threads

  1. select item from dropdown list on webpage
    By Datadayne in forum .NET
    Replies: 0
    Last Post: 09-16-2010, 02:52 PM
  2. In a VB6 Playlist - need to select new song
    By paul1145 in forum VB Classic
    Replies: 1
    Last Post: 07-06-2010, 03:55 PM
  3. Replies: 2
    Last Post: 12-10-2008, 07:18 PM
  4. pl/sql stored procedure tuning
    By shiva_vaddadi in forum VB Classic
    Replies: 1
    Last Post: 06-08-2006, 09:43 AM
  5. Select a specific item inside of listbox
    By thphaca in forum VB Classic
    Replies: 3
    Last Post: 08-03-2005, 09:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center