Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Retrieve text under cursor VB

vaughantvaughant Posts: 2Member
How do I capture text highlighted by the cursor in any open
window when user presses a predefined key on the keyboard

Would most appreciate any help

Comments

  • VBNertVBNert Posts: 20Member
    : How do I capture text highlighted by the cursor in any open
    : window when user presses a predefined key on the keyboard
    :
    : Would most appreciate any help
    :
    maybe you can capture it by telling your program that that button is the copy button for your clipboard, so that if you press the button, the highlighted text will be copied to your clipboard, so you can retreive it in your program?
  • lionblionb Posts: 1,685Member
    : How do I capture text highlighted by the cursor in any open
    : window when user presses a predefined key on the keyboard
    :
    : Would most appreciate any help
    :
    [code]
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then 'Enter key pressed
    MsgBox Text1.SelText 'selected text
    End If
    End Sub
    [/code]
  • VBNertVBNert Posts: 20Member
    [b][red]This message was edited by VBNert at 2006-6-26 7:4:41[/red][/b][hr]
    : : How do I capture text highlighted by the cursor in any open
    : : window when user presses a predefined key on the keyboard
    : :
    : : Would most appreciate any help
    : :
    : [code]
    : Private Sub Text1_KeyPress(KeyAscii As Integer)
    : If KeyAscii = vbKeyReturn Then 'Enter key pressed
    : MsgBox Text1.SelText 'selected text
    : End If
    : End Sub
    : [/code]
    :
    i dont think he wanted to know that :) ANY open window can be IE or msword or whatever program. so then it would be something like this:

    [code]
    Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    if keycode=vbkeyesc then
    sendkeys("ctrl" + "c")
    text1.setfocus
    sendkeys("ctrl" + "v")
    end if
    [/code]
    should be something like this
    or something with the GetAsyncKeyState() api


Sign In or Register to comment.