CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Copying Text

  1. #1
    Join Date
    Mar 2000
    Location
    Arizona, USA
    Posts
    493

    Copying Text

    I have an app that runs in the background all the time. If IE is open and the hotkey(F2) is pressed
    my app becomes visible. I need some help in one area though. I need to copy text that is highlighted
    on the web page into a textbox on my form. Can anyone tell me how to do this? I have tried and
    tried but have not had any success.
    Thanks for any help provided. All posts that help me with this problem will be rated.

    Kris
    Software Engineer
    Phoenix,AZ
    Kris
    Software Engineer
    Phoenix, AZ USA

  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Copying Text

    Obtain a window handle to Explorer and before you bring your application to the foreground send it a WM_COPY message with the SendMessage API call.

    If any text is selected it will be copied to the clipboard.

    HTH,
    Duncan



    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Mar 2000
    Location
    Arizona, USA
    Posts
    493

    Re: Copying Text

    I tried that exactly as you have described and it does not work. I know I had the correct hWnd to
    the window because I could change the window title bar text. I have figured out a different
    way to do this. I added my program to the right click menu of IE and used javascript to get the
    highlighted text then open my app and pass the text as a command line argument. Works great.

    Kris
    Software Engineer
    Phoenix,AZ
    Kris
    Software Engineer
    Phoenix, AZ USA

  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Copying Text

    Hmm - does Sendkeys "^C" work?

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  5. #5
    Join Date
    Mar 2000
    Location
    Arizona, USA
    Posts
    493

    Re: Copying Text

    Nope that didn't work either. I tried several different ways but no luck. The JavaScript works
    great though.

    Kris
    Software Engineer
    Phoenix,AZ
    Kris
    Software Engineer
    Phoenix, AZ USA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured