SendKeys Method

Description

This method sends a string of keystrokes to the virtual screen. This method acts as if keystrokes were being typed from the keyboard of a terminal. The keystrokes will be sent to the location given. If no location is provided, the keystrokes will be sent to the current cursor location.
 

Applies To Objects

Screen
 

Syntax

Screen.SendKeys( text, location )
 

Parameters

Parameter
Description
text
String of characters to be sent to the virtual screen.
location

The offset position where the string of keys is to be written. For row 1 column 1 of the screen display buffer, the offset is 0.

 

Return Values

None
 

Sample VB Code

Public AllSessions As OhioSessions
Public WithEvents MySession As OhioSession
Public MyScreen As OhioScreen

Private Sub Form_Load()

Set AllSessions = New OhioSessions
Set MySession = AllSessions.AddSession("C:\test.zcc", 1)
Set MyScreen = MySession.Screen

MySession.Connect

End Sub

Private Sub Command1_Click()

MyScreen.SendKeys "log", MyScreen.Cursor
MyScreen.PutString "on", MyScreen.Cursor
MyScreen.SendAid OHIO_KEY_ENTER

End Sub

Private Sub MySession_OnScreenChanged(ByVal inUpdate As OHIO_UPDATE, ByVal inStart As Long, ByVal inEnd As Long)

Label1 = MyScreen.String

End Sub

Private Sub Form_Unload(Cancel As Integer)

MySession.Disconnect
AllSessions.CloseSession MySession.SessionName

End Sub

Sample C++ Code

#define OHIO_UPDATE_HOST 0
#define OHIO_UPDATE_CLIENT 1
#define OHIO_DIRECTION_FORWARD 0
#define OHIO_DIRECTION_BACKWARD 1
 

BEGIN_DISPATCH_MAP(CMyView, CView)

DISP_FUNCTION_ID(CMyView, "OnScreenChanged",  1, OnScreenChanged,  VT_EMPTY, VTS_I4 VTS_I4 VTS_I4)

END_DISPATCH_MAP()

void CMyView::OnScreenChanged(long iUpdate, long iStart, long iEnd)
{

if ( iUpdate == OHIO_UPDATE_HOST )
{

long nPos;
// simple screen recognition for logon screen
nPos = m_MyScreen.FindString("logon", 1609, 5, OHIO_DIRECTION_FORWARD, TRUE);
if ( nPos >= 0 )
{

m_MyScreen.SendKeys( "logon p390a", m_MyScreen.GetCursor() );
m_MyScreen.SendAid( OHIO_KEY_ENTER );

}
nPos = m_MyScreen.FindString( "password", 564, 8, OHIO_DIRECTION_FORWARD, TRUE );
if ( nPos >= 0 )
{

m_MyScreen.PutString( "ibm3270", m_MyScreen.GetCursor() );
m_MyScreen.SendAid( OHIO_KEY_ENTER );

}

}

}

Sample C# Code

try

{

screen.SendKeys ("1", screen.Cursor);

screen.SendAid (OHIO_KEY_ENTER); // Send the ENTER key

}

catch (Exception ex)

{

MessageBox.Show ("Exception: " + ex);

}