我正在尝试构建一个在IBM i(AS400)上运行的应用程序。到目前为止,我可以让应用程序打开并登录,但我正在寻找动态解决方案而不是使用静态发送密钥
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}")
End Sub
End Class
我可以运行一个宏,显示一个输入密码的弹出框
Sub Macro1()
'
' Generated by the Reflection Macro Recorder on 03-18-2015 13:03:31.50
' Generated by Reflection for IBM for Windows 8.00
'
With Session
Dim hostpassword As String
.WaitForEvent rcEnterPos, "30", "0", 6, 53
.WaitForDisplayString ".", "30", 6, 49
.TransmitANSI "USERID"
.TransmitTerminalKey rcIBMTabKey
hostpassword = "PASSWORD"
.TransmitANSI hostpassword
.TransmitTerminalKey rcIBMEnterKey
End With
End Sub
我无法将其复制并粘贴到visual studio中并以此方式工作。所以我的问题是如何让一个文本框将所输入的内容注入外部应用程序的命令行?我已经做了大量的研究,但我发现的大部分内容并不适用于我尝试的内容,因为我发现的每个教程都面向MS Office,Excel大多。有人可以指出我正确的方向吗?
答案 0 :(得分:1)
请参阅Host Access Class Library Automation Objects。
这是我多年前写的重新连接会话的示例VB脚本:
Option Explicit
Dim autECLConnList As Object
Dim i As Integer
Set autECLConnList = CreateObject("PCOMM.autECLConnList")
autECLConnList.Refresh
If autECLConnList.Count > 0 Then
For i = 1 to autECLConnList.Count
If autECLConnList(i).CommStarted Then
autECLConnList(i).StopCommunication()
End If
autECLConnList(i).StartCommunication()
Next
End If
答案 1 :(得分:0)
感谢您的回复,但是我没有任何连接问题因为程序打开并且登录得很好,我只想弄清楚如何从我的表单中获取文本到AS400而我没有&#39我意识到解决方案很简单,我很惊讶没有人回答,或者他们正等着我自己解决这个问题
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(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
End Class