Results 1 to 5 of 5

Thread: VB and Clipboard

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    North Carolina
    Posts
    4

    Question

    Using vb6.0

    I have a form which is "always on top." I want to be able to select (highlight) text in any app and the click a button on my form (which is on top) and copy the selected text to the clipboard.


    I have tried using:
    << Clipboard.SetText Screen.ActiveControl.SelText >>

    but, the window containing the highlighted text is no longer the active window.

    How do I reference a window which is no longer active (or was the last active)?


    I thought about opening apps within a VB window and using:
    << Clipboard.SetText ActiveForm.ActiveControl.SelText >>

    but, this is not my best resolve.


    Any ideas?

    Stephen Robertson

  2. #2
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241
    ok, i don't know if this will work or no,,,but i will give it a go,,,
    try to add a timer,,,which checks the selected text,,if there is a selected text then it saves it in a string, it saves the last selected text only,,,then when you press your button,, it copy that string into the clipboard,, i don't have any code right now,,its just an idea
    hope it works

  3. #3
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241

    Lightbulb one more thing...

    one more thing,, this Screen.ActiveControl.SelText it only woks within your app. , that means it will not work for any other app but yours,,,

  4. #4
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    Try this.


    Private Sub Command1_Click()
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    Text1.SetFocus
    Clipboard.Clear
    Clipboard.SetText Text1.SelText

    End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    North Carolina
    Posts
    4
    I understand the limitations of <<screen.ActiveControl.SelText>>

    The idea of the timer is interesting, but how do you look for "the last selected text only" especially in another app?

    There is a product doing this. They place an icon in the system tray which functions using a left or right mouse click.


    Since I want this to function with various file types, I thought about opening a "default-type" viewer within the VB app. This would allow the use of <<screen.ActiveControl.SelText>>.

    The problem here is document format. Will I loose the oroginal format? Will the document be too altered as to be unrecognizable...? This is something I wish to market, so it must look (good!).

    My first choice is to trythe first approach with external apps. This way, I have less concerns about formats.
    Stephen Robertson

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