Communicate Directly with Clients
To obtain display screen information from a
client
application, VShell uses a technique called scraping. Scraping means that VShell regularly captures images of the screen and then uses those images to update what is being displayed on the client's screen. This can mean, however, that data that appears and disappears from the screen between image captures may be lost. It also means that ESC sequences, which are not displayed on screen, are not recognized. Under such circumstances, you may need to bypass VShell's scraper and communicate directly with the client application.
VShell allows you to communicate directly with a client application by using a "pipe" the name of which is stored in the VSHELL_PIPE environment variable. This allows you to pass data through to the client that would normally be processed by the scraper. For example, in order to use the pass-through printing feature in VanDyke Software's SecureCRT®, you would need to use VShell's pipe.
Note: If you use the VShell pipe feature to change the appearance of your screen, VShell will not be aware of the change until something causes the entire screen to repaint.
The following VBScript example can be run using the cscript command and will print the contents of a file using pass-through printing The cscript command is as follows:
c:\> cscript print.vbs myfile.txt
The VBScript file print.vbs would be as follows:
Const ForReading = 1
Set shell = CreateObject("WScript.Shell")
Set fsoSysObj = CreateObject("Scripting.FileSystemObject")
Set environment = shell.Environment("process")
Set args = WScript.Arguments
Main
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub Main
If ( args.Count < 1 ) Then
WScript.Echo "Usage: cscript passprint <filename>"
Exit Sub
End If
Set src = fsoSysObj.OpenTextFile(args(0), ForReading)
Set dst = fsoSysObj.CreateTextFile(environment("VSHELL_PIPE"), True)
dst.Write chr(27) & "[5i"
' Now, loop reading file and writing pipe
Do While src.AtEndOfStream <> True
line = src.Readline
dst.WriteLine line
Loop
dst.Write chr(27) & "[4i"
End Sub