PASSPORT Knowledge Base
Macros

Date Published: November 21, 2011

Title

Macro to Determine if User Has Selected an Area of the Screen

Product

PASSPORT PC to Host, PASSPORT Web to Host

Emulation Types

TN3270, TN5250, VT, SCO ANSI, Wyse 60

Issue

Is it possible to determine if a user has an area of the screen selected during execution of a macro? If so, we are interested in copying the area that is currently selected. However, if nothing is currently selected, we would like to copy the entire contents of the current screen. Is there a PASSPORT macro function that can do this?

Solution

Although there is not a PASSPORT macro function that can do this, below is a sample .ZAM macro that may be used to accomplish this.

Example

Below is a sample PASSPORT macro that uses the Microsoft Word application object to obtain the contents of the Windows clipboard after issuing a PASSPORT copy command. If the variable created contains data it will be displayed in a dialog box. Otherwise, if it is null, the entire screen contents is selected, copied and displayed:
 

Sub Main

' Set the contents of the clipboard to nothing:

strMessage = ""

 

' Create the Word application object:

Set objWord = CreateObject("Word.Application")  

With objWord    

.Visible = False ' Don't show word

.Documents.Add ' Create a document

.Selection.TypeText strMessage  ' Put text into it  

.Selection.WholeStory ' Select everything in the doc

.Selection.Copy ' Copy contents to clipboard

.Quit False ' Close Word, don't save

End With

Set objWord = Nothing

 

' Execute PASSPORT copy command:

ExecMenuCmd ("Edit-Copy")

 

' Set variable to clipboard contents:

Set objHTML = CreateObject("htmlfile")

strArea = objHTML.ParentWindow.ClipboardData.getData("text")

 

If strArea <> "" Then

MsgBox strArea

Else

ExecMenuCmd ("Edit-Select All")

ExecMenuCmd ("Edit-Copy")

Wait(2)

strArea = objHTML.ParentWindow.ClipboardData.getData("text")

MsgBox strArea

End If

 

Set objHTML = Nothing

End Sub

More Information

Keywords

macro, area, screen, selected, copy, clipboard, Word, object, .ZAM