Results 1 to 4 of 4

Thread: [RESOLVED] Question about SendKeys.Send

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    123

    Resolved [RESOLVED] Question about SendKeys.Send

    Hello,

    I have a question regarding SendKeys.Send; everything I've read leads me to believe this code should output the text I assign SendKeys at the cursor location in google, but when the program activates SendKeys, webbrowser1 looses focus and there is no output. Any ideas what I'm doing wrong? As a polite request, I already know how to do this using html.elements, but I'd like to try it a different way all the same; thank you.

    Code:
    Public Class Form1
    
       Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
           WebBrowser1.Navigate("www.google.com")
       End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            WebBrowser1.Focus()
            SendKeys.Send("yahoo!")
    
        End Sub
        
    
    End Class

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Question about SendKeys.Send

    try,
    Code:
    WebBrowser1.Document.Body.Focus()
    SendKeys.Send("yahoo!")

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    123

    Re: Question about SendKeys.Send

    Nope . As soon as I click the button, the cursor just disappears as if the program focuses on another part of the document and no text is displayed. I should mention that I've tried multiple web sites, not just google.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    123

    Re: Question about SendKeys.Send

    Humm, I have nooooo idea why it wasn't working! I made a completely new worksheet and just input the code raw, no copy/paste, and now it works?!? Literally, nothing is different than what is in that code. Very strange. Well at least I know it works ! I'll add to your rep.

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