使用 Attachmate,我正在尝试编写一个 VBA 脚本,该脚本在特定短语出现时做出反应并通过内联命令自动执行命令。本质上,当出现一个短语时,会出现一个输入框,要求用户输入特定数量,VBA 代码获取该数量,将其插入终端,然后在不同的菜单中跳转以创建内部标签。但是,我的问题是我不知道如何让 VBA 代码对主机可能返回的不同字符串做出反应。有时它说“进入继续”,有时它说“选择用户”。所以我想要它做的是基于它接收到的语句来执行某个操作,但我不知道用于捕获终端从主机接收到的内容的命令是什么。我试过“waitforstring”和“
'variable declarations
Dim count As Long 'var used to indicate how many times code should loop (how many labels should be print)
Dim drugname As String
Dim qtyinput As Long
Dim CR As String ' Chr(rcCR) = Chr(13) = Control-M
Dim LF As String ' Chr(rcLF) = Chr(10) = Control-J
Dim strcheck As String
'assign values to variables
count = 0
CR = Chr(Reflection2.ControlCodes.rcCR)
LF = Chr(Reflection2.ControlCodes.rcLF)
qtyinput = InputBox("Number of items being sent", Quantity)
drugname = .GetText(22, 15, 22, 46) ' StartRow:=22, StartColumn:=15,EndRow:=22, EndColumn:=46 'copies text from screen
' Press EditCopy (Copy the selection and put it on the Clipboard).
'.Copy rcSelection, rcAsPlainText -- not needed
.Transmit qtyinput & CR
.Transmit CR
'strcheck = .readline("00:00:01")
'MsgBox strcheck
'If .WaitForString("Press " & Chr(34) & "RETURN" & Chr(34) & " to continue, " & Chr(34) & "^" & Chr(34) & " to stop: ") Then .Transmit CR
'Select Case strcheck
' Case strcheck Like "to continue"
' .Transmit CR
'Case strcheck Like "*Select CLIENT*"
' .Transmit CR
'End Select
.Transmit "^MED" & CR
.Transmit "3" & CR
.Transmit "10" & CR