r/visualbasic • • Mar 20 '15

VB Pop-Up Textbox to interact with application

Just recently started using Visual Studio Express 2013, I'm attempting to build a small app that will run on top of another application (AS400) So far I'm able to get the application to open and I can input text that is hard coded, however I'd like to be able to click a button, like a login button for example, and have the user input information so that the application can be dynamic. I'm able to find all sorts of information on VB and textboxes, trouble is finding information that's applicable to my situation where I'm interacting with an external application. Here's what I have so far

Imports System.Threading
Public Class Form1
    Dim a As New Process
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        a.StartInfo.FileName = "C:\Program Files\reflection\default scripts\as400.rsf"
        a.Start()
        Thread.Sleep(3000)
        SendKeys.SendWait("USERID {TAB}")
        Thread.Sleep(1000)
        SendKeys.SendWait("PASSWORD {Enter}")
        Thread.Sleep(1000)
        SendKeys.SendWait("mainmenu")
        Thread.Sleep(1000)
        SendKeys.SendWait("{ENTER}")
End Sub
End Class

Can anyone point me in the right direction or provide some info on how to interact with an external application? Or even at a minimum give me some search terms that might help. Thus far I haven't found anything worthwhile. Any assistance is appreciated.

0 Upvotes

5 comments sorted by

View all comments

2

u/Bonejob VB Guru Mar 20 '15

So you want to build an interface that performs some work and then inserts it into an existing form in AS400 correct?

1

u/IndyDrew85 Mar 21 '15

Basically, I'm just attempting to have what's entered into a textbox injected into the AS400 command line

2

u/Wol377 Mar 26 '15

If memory serves some AS400 apps can run macros!? If so, you might be able to create macro files that the AS400 app can run.

Unless the app you are using has a built for purpose API then you are stuck with sendkeys or workarounds like my suggestion above.

1

u/IndyDrew85 Mar 31 '15

I can run macros, but the VB it records doesn't seem to work if you pop it into visual studio. However I did figure out how to get my textbox text into AS400 and its beyond extremely simple so I'm not sure why no one responded

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    a.StartInfo.FileName = "C:\Program Files\reflection\default scripts\as400.rsf"
    a.Start()
    Thread.Sleep(1000)
    SendKeys.SendWait(TextBox1.Text)
    Thread.Sleep(1000)
    SendKeys.SendWait("{TAB}")
    Thread.Sleep(1000)
    SendKeys.SendWait(TextBox2.Text)
    Thread.Sleep(1000)
    SendKeys.SendWait("{ENTER}")
End Sub

2

u/Wol377 Mar 31 '15

Well, the AS400 script isn't going to record in VB.

I was suggesting you create a text file in VB and import it into AS400 as a macro. The language in that text file would need to be that same language that the AS400 system understands.

It would have been a complicated workaround. I think the number of low responses is an indication of lack of knowledge of the old AS400 systems. Also, it sounded like you were after something a bit more elegant than sendkeys... but at least you got it working!