none
VB.NET] How to input the text on the notepad in real time whenever I click the button. RRS feed

  • 질문

  • Hi there, 

    Whenever I click the button1, the word “Textbox1.text” should be entered in the notepad.

    It means when I click the button1 once, notepad is run and “Textbox1.text” is inputted.

    When I click the button1 again, notepad is already run so that “Textbox1.text” is just inputted under first Textbox1.text”.

    However, whenever I click the below code button1, new notepad is run.

    Could you let us know the reason why this kind of matters happens again? 

    Your prompt reply will be highly appreciated.  

    -code-

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim p As Process = New Process
            Dim pID As Integer
    
            If pID.ToString() = "0" Then
                p.StartInfo.FileName = "notepad.exe"
                p.Refresh()
                p.Start()
                pID = p.Id
                p.WaitForInputIdle(1000)
            End If
    
            AppActivate(pID)
            SendKeys.SendWait(TextBox1.Text)
            SendKeys.SendWait("{enter}")
    
        End Sub

    2013년 7월 13일 토요일 오후 12:31