There is very little else to say about how to automate A-Shell, which has not been stated in the previous sections. The ATE (A-Shell Terminal Emulator) code sample included within the A-Shell ActiveX SDK is a good example of a real application which uses automation in order to use A-Shell to provide functionality it requires. The process of automating A-Shell can be summarised as the following steps.
Firstly make sure the A-Shell application is registered on the machine on which the Visual Basic code is to be developed. This occurs as a natural part of the A-Shell installation, but can be explicitly performed by executing the following at the command prompt:
ASHW32 –regserver
This step will create entries in the registry which detail the ProgIDs, ClassIDs, and properties and methods of all A-Shell classes.
Next, make sure a reference to A-Shell is created within the Visual Basic project to contain the automating code. This can be achieved by choosing ‘Project, References’ from the Visual Basic menu, and then ensuring the following is selected:
A-Shell x.y Object Library (x.y represents the A-Shell Version)
Any project type can be used to automate A-Shell, but will usually be a standard executable (EXE). The code to automate A-Shell should then first create an early-bound instance of the A-Shell application:
Dim oAshell As Ashw32Lib.Application
’
Set oAshell = New
Ashw32Lib.Application
At this point, A-Shell is not yet running, and the value of the Visible property can now be set to determine whether the A-Shell window is made visible when it is initially created. The next step is to activate, or launch the A-Shell application:
oAshell.Activate ””
See the appropriate Interface Reference Chapter for more detail on the Activate method.
This call will return immediately as the A-Shell application starts to run. However, it may not necessarily be ready for use, as it may be displaying a demonstration mode message, or prompting for a license key. In order to play it safe, it is then best to wait for the A-Shell to be at the command prompt:
Do While Not oAshell.AtPrompt
DoEvents
Loop
The A-Shell application object is then ready for use – probably with the ExecCmd method.