When BlueZone is running in the Visual Basic application,
it can be controlled using the BlueZone Host Automation Object. It
is instantiated using the CreateObject method. When
created, any of the BlueZone Host Automation Object's methods and
properties can be called by your Visual Basic application.
The following sample code shows the correct way to instantiate
the BlueZone Host Automation Object in a VB project when the session
is being embedded in a VB Form:
Option Explicit
Dim bzhao As Object
Private Sub Form_Unload(Cancel As Integer)
bzhao.Disconnect
End Sub
Private Sub Sglw2hcm1_AfterConnect(ByVal Success As Long)
Set bzhao = CreateObject("BZWhll.WhllObj")
Bzhao.SetCursorBase 1
bzhao.SetFormWnd Me.Hwnd
bzhao.Connect "!"
bzhao.WaitForText "Choice:", 23, 7, 10
bzhao.SendKey "3"
bzhao.SendKey "<Enter>"
bzhao.WaitReady 10, 1
End Sub
The above sample code is designed to work with
any BlueZone session type and uses the Web-to-Host Control Module’s
AfterConnect event for notification that the session is ready for
automation.
To use it as a test, follow these steps:
- Start a BlueZone Display session.
- Configure the session to auto-connect to a host system
on startup.
- In addition to host IP address and port, make any additional
configuration changes at this time. All BlueZone features including
the keyboard map, display colors, display font, toolbar settings,
and so on are contained in the BlueZone configuration file.
- Save the BlueZone configuration and name it, for example, test.zmd.
- Create a Visual Basic Project, insert the BlueZone Web-to-Host
control module in a form, and ensure that your BlueZone Web-to-Host
Control Module is configured properly. Specify the configuration
file name saved in the previous step as the Profile value in the Web-to-Host
control’s Sessions tab.
Refer to the following topics for more information:
- Insert the above sample code into your Visual Basic project.
Modify or remove any lines after the .Connect() method to navigate
your particular host.
-
Click the Start icon
to run the
application.
BlueZone Display opens in the form, connects to the host system, and then
the BZHAO is used to automate the session.
- After the session is embedded and running in the form,
you can control it using the Host Automation Object. The following
sample code from above is used to create the object and connect it
to the embedded session:
Set bzhao = CreateObject("BZWhll.WhllObj") ‘instantiate the BZHAO
bzhao.SetCursorBase 1 ‘use 1-based row and column values
bzhao.SetFormWnd Me.Hwnd ‘set the embedded session’s parent window
bzhao.Connect "!" ‘connect object to the embedded session
The above sample code demonstrates the ability for BlueZone
to automatically connect to a host, wait for a specific string of
characters to display on the screen, and navigate to a specific location
on the host.