Skip to main content

I created a simple form to interface with Rumba using the ObjectXMFDisplay libray.  I was able to get the display setup and the connection but when I use the Send Keys function it keeps trying to send keys without pausing for the screen to update after enter.  How can I get it to pause between send key functions?

I did try putting a pause in but it just paused before the first command.

My send keys code.

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
     AxObjectXMFDisplay1.SendKeys("Text1@E")
        
     AxObjectXMFDisplay1.SendKeys("Text2@E")
End Sub


#Rumba

I created a simple form to interface with Rumba using the ObjectXMFDisplay libray.  I was able to get the display setup and the connection but when I use the Send Keys function it keeps trying to send keys without pausing for the screen to update after enter.  How can I get it to pause between send key functions?

I did try putting a pause in but it just paused before the first command.

My send keys code.

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
     AxObjectXMFDisplay1.SendKeys("Text1@E")
        
     AxObjectXMFDisplay1.SendKeys("Text2@E")
End Sub


#Rumba

Hi rumba_user,

unfortunately there is no built-in mechanism in SendKeys to wait for the complete host response before continuing. There are a couple of things which need to happen before a macro can continue.

1. The operator information area much be in a ready state.

2. The entire screen needs to have been received by the terminal.

    note: A 3270 screen can arrive in multiple packets, normally a full screen will arrive in two,

    the top half and the bottom half. Depending on which arrives first the OIA may be put into a

    ready state before the full screen has been received, so one has to take that into account also.

Normally I create a routine which I use to wait for the host to be ready before I start sending more data.

Here is some sample code:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Function ScreenReady(WaitTime As Long) As Boolean

   ScreenReady = False

   For i = 1 To (WaitTime * 5)

       DoEvents

           If ObjectXMFDisplay1.ReadyToSend = 1 Then

           ScreenReady = True

           Sleep 200

           Exit For

       End If

       Sleep 200

   Next i

End Function

Sub Settle()

   For i = 1 To 10

       DoEvents

       Sleep 100

   Next i

End Sub

The first routine above checks every 200 milliseconds to see if the OIA is in a ready state and exits once the ReadyToSend property is set True/1, and your can pass a timeout parameter in second to the function.

The second routine is a hardcoded loop of 1 second, this to allow time for all packets to be received (in case we get the OIA packet first.

Depending on your network and normal host responses you may be able to reduce the number of loops in the Settle routine.

Here are some sample calls to SendKeys using the above screen handling routines.

Private Sub CommandButton1_Click()

   ObjectXMFDisplay1.SendKeys ("TSO@E")

   If ScreenReady(3) = False Then

       MsgBox "Not Ready"

       End

   End If

   Settle

   ObjectXMFDisplay1.SendKeys ("username@E")

   If ScreenReady(3) = False Then

       MsgBox "Not Ready"

       End

   End If

   Settle

   ObjectXMFDisplay1.SendKeys ("password@E")

   If ScreenReady(3) = False Then

       MsgBox "Not Ready"

       End

   End If

   Settle

   ObjectXMFDisplay1.SendKeys ("@E")

End Sub


I created a simple form to interface with Rumba using the ObjectXMFDisplay libray.  I was able to get the display setup and the connection but when I use the Send Keys function it keeps trying to send keys without pausing for the screen to update after enter.  How can I get it to pause between send key functions?

I did try putting a pause in but it just paused before the first command.

My send keys code.

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
     AxObjectXMFDisplay1.SendKeys("Text1@E")
        
     AxObjectXMFDisplay1.SendKeys("Text2@E")
End Sub


#Rumba

Hi rumba_user,

unfortunately there is no built-in mechanism in SendKeys to wait for the complete host response before continuing. There are a couple of things which need to happen before a macro can continue.

1. The operator information area much be in a ready state.

2. The entire screen needs to have been received by the terminal.

    note: A 3270 screen can arrive in multiple packets, normally a full screen will arrive in two,

    the top half and the bottom half. Depending on which arrives first the OIA may be put into a

    ready state before the full screen has been received, so one has to take that into account also.

Normally I create a routine which I use to wait for the host to be ready before I start sending more data.

Here is some sample code:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Function ScreenReady(WaitTime As Long) As Boolean

   ScreenReady = False

   For i = 1 To (WaitTime * 5)

       DoEvents

           If ObjectXMFDisplay1.ReadyToSend = 1 Then

           ScreenReady = True

           Sleep 200

           Exit For

       End If

       Sleep 200

   Next i

End Function

Sub Settle()

   For i = 1 To 10

       DoEvents

       Sleep 100

   Next i

End Sub

The first routine above checks every 200 milliseconds to see if the OIA is in a ready state and exits once the ReadyToSend property is set True/1, and your can pass a timeout parameter in second to the function.

The second routine is a hardcoded loop of 1 second, this to allow time for all packets to be received (in case we get the OIA packet first.

Depending on your network and normal host responses you may be able to reduce the number of loops in the Settle routine.

Here are some sample calls to SendKeys using the above screen handling routines.

Private Sub CommandButton1_Click()

   ObjectXMFDisplay1.SendKeys ("TSO@E")

   If ScreenReady(3) = False Then

       MsgBox "Not Ready"

       End

   End If

   Settle

   ObjectXMFDisplay1.SendKeys ("username@E")

   If ScreenReady(3) = False Then

       MsgBox "Not Ready"

       End

   End If

   Settle

   ObjectXMFDisplay1.SendKeys ("password@E")

   If ScreenReady(3) = False Then

       MsgBox "Not Ready"

       End

   End If

   Settle

   ObjectXMFDisplay1.SendKeys ("@E")

End Sub


I created a simple form to interface with Rumba using the ObjectXMFDisplay libray.  I was able to get the display setup and the connection but when I use the Send Keys function it keeps trying to send keys without pausing for the screen to update after enter.  How can I get it to pause between send key functions?

I did try putting a pause in but it just paused before the first command.

My send keys code.

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
     AxObjectXMFDisplay1.SendKeys("Text1@E")
        
     AxObjectXMFDisplay1.SendKeys("Text2@E")
End Sub


#Rumba

Hi rumba_user,
you also can check out the RDE_Functions. 

  • RDE_Connect_Hsynch Method
  • RDE_Connect_Hsynch Method

RDE_SendKeys_Hsynch Method
Use this method to navigate to a host destination screen. RDE_SendKeys_Hsynch uses the SendKeys method to send the specified keystrokes to the host application. A return code indicates whether the destination host screen was reached and is ready to be processed for data extraction or navigation

Syntax:
<object>.RDE_SendKeys_Hsynch(String Keys, Boolean bWaitForEvents, Long nWaitCount, Long nTimeOut, string szVerString, Long row, Long col)

Values

Parameter Description

Keys
String containing the keystrokes to send to the host at the current cursor location. This string can contain only one AID key, which must be specified as the last string character. For example: userid@Tpword@E

Note: @T is not an AID key (it doesn’t send the screen to the host for processing).

bWaitforEvents
Specifies which host synchronization mode to use:

When TRUE (any non zero value), the RDE_Connect_Hsynch method waits for the number of ReadyToSend(TRUE) events specified in the nWaitCount parameter.

When FALSE, this property waits for a "settle time" interval (see the nWaitCount parameter) where no HostScreenChange events fire and RTS remains (True).

nWaitCount
When bWaitForEvents is TRUE, specifies the number of ReadyToSend(TRUE) events to wait for. We recommend using 1 as the default and modifying this value as needed. You can use a utility like RDE Factotum to count the actual number of events.

When bWaitForEvents is FALSE, specifies a default "settle time" in milliseconds of 1000 (that is, 10 seconds) if set to any value less than 101. This settle time is a small wait period (usually less than a second) that ensures the display screen is ready to process incoming keys or events.

nTimeout
Specifies the time in milliseconds to wait if no other event causes the function to return. The default value is 10000 milliseconds if 0 is passed as this parameter.

szVerString
(Optional, or blank if not used)

Specifies a case-sensitive string to search for on the host screen. If an empty string is passed, this parameter is ignored.

Use szVerString to verify whether the current host screen is the intended destination screen or an unexpected screen. For example, if the user enters an incorrect ID at the sign-on screen, the host displays an error message. You can use szVerString to search for a verification string on the destination screen, or to search for a host message on the current screen.

To search for a host string, you must specify the search location using the row and col parameters.

All search strings are treated literally unless they contain asterisks only.

To search for any string, use a string consisting only of asterisk (*) characters, where the number asterisks specifies the length of the search region to search. For example,
if row = 10, col = 20, and szVerString = ****
this method returns when any text is found at location 10,20 or 10,21 or 10,22 or 10,23.

If the search string is found, the RDE_Connect_Hsynch method returns immediately regardless of the ReadyToSend(TRUE) value. However, the method does check the count before exiting and returns APIOK if both conditions are met.

row
(Required when using szVerString or 0 if not used)
Specifies the row to search for szVerString in the screen buffer.

col
(Required when using szVerString or 0 if not used)
Specifies the column to search for szVerString in the screen buffer.


Return Code

Value
Constant
Description

0
wdAPIOK
bWaitForEvents is TRUE, the number of ReadyToSend events in nWaitCount was reached, and szVerString was found at the specified row and col.

1
wdAPIRTSCountReached
bWaitForEvents is TRUE and the number of ReadyToSend events in nWaitCount was reached, but szVerString was not found.

5
wdAPInhibited
Inhibited or keyboard locked

6
wdAPIStringFound
szVerString was found at the specified row and col. This occurred before the number of events was reached, or before the settle time elapsed if bWaitForEvents is FALSE.

7
wdAPITimedOut
The function terminated because the timeout interval elapsed.

8

(Pro Control)
wdAPISettleTimeReached
The settle time elapsed, bWaitForEvents is FALSE, and szVerString is blank or not found.


Remarks

If more than one termination event occurs (for example, bWaitForEvents is TRUE and szVerString is found), RDE_SendKeys_Hsynch uses the return value of the first event to triggers the function termination.

If the internal call to the display session’s SendKeys method fails, RDE_SendKeys_Hsynch uses the return value of the SendKeys method.

You can use the call parameters to customize the RDE_SendKeys_Hsynch method for performance and reliability.

code snippet:

lRC = MFForm.Dsp1.RDE_Connect_Hsynch(True, 2, 10000, "", 0, 0)
If lRC > 6 Then
MsgBox "Error - unable to connect to host"

MFForm.Dsp1.RDE_SendKeys_Hsynch "tso@E", True, 3, 10000, "", 0, 0

lRC = MFForm.Dsp1.RDE_SendKeys_Hsynch("qtest6@E", True, 1, 10000, "", 0, 0)

lRC = MFForm.Dsp1.RDE_SendKeys_Hsynch("qatest@E", True, 5, 10000, "", 0, 0)

MFForm.Dsp1.RDE_SendKeys_Hsynch "@E", True, 1, 10000, "", 0, 0

MFForm.Dsp1.RDE_SendKeys_Hsynch "@C", True, 1, 10000, "", 0, 0

MFForm.Dsp1.RDE_SendKeys_Hsynch "@3", True, 2, 10000, "", 0, 0

MFForm.Dsp1.RDE_SendKeys_Hsynch "listcat@E", True, 2, 10000, "", 0, 0


I created a simple form to interface with Rumba using the ObjectXMFDisplay libray.  I was able to get the display setup and the connection but when I use the Send Keys function it keeps trying to send keys without pausing for the screen to update after enter.  How can I get it to pause between send key functions?

I did try putting a pause in but it just paused before the first command.

My send keys code.

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
     AxObjectXMFDisplay1.SendKeys("Text1@E")
        
     AxObjectXMFDisplay1.SendKeys("Text2@E")
End Sub


#Rumba

Thank you andre, your solution worked perfectly.