Copy and paste example

The following example shows how to mark a block of text in the session window, copy it to the system clipboard, and paste it back into the session window at a new location. This example uses the following action elements: Box selection action, Input action, Mouse click action, and Pause action.

You can copy the text of this macro script from this document into the system clipboard, and then from the system clipboard into the Code Editor (see Copy and paste a script from this guide into the Code Editor). After you save this script in the Macro Editor, you can edit it either with the Macro Editor or with the Code Editor.

You should notice the following facts about this example:
  • The example consists of one entire macro script named COPY PASTE.
  • The following actions occur in the <actions> element:
    • The <boxselection> action draws a marking rectangle.
    • A <pause> action waits one-half second so that when the macro is played back, the user can see what is happening.
    • An <input> action types a [copy] action, which copies the marked area to the clipboard.
    • A <mouseclick> action sets the cursor to the location where the paste will take place.
    • An <input> action types a [paste] key, which pastes the contents of the clipboard to the new location on the session window.
  • This macro is written to be run from the ISPF Primary Option Menu (see Figure 2). The macro copies the text Spool Display and Search Facility from row 18 to the system clipboard, and then pastes the text from the clipboard to the Option ===> input field in line 4.
  • If this example does not paste properly when you run it, make sure that the target area that you have specified lies within a 3270 or 5250 input field. The Z and I Emulator for Web client does not let you paste text into a protected field in the application screen.
Figure 1. Sample code COPY PASTE
<HAScript name="COPY PASTE" description=" " timeout="60000" pausetime="300"
            promptall="true" author="" creationdate="" supressclearevents="false"
            usevars="false" >

   <screen name="Screen1" entryscreen="true" exitscreen="true"
         <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
         <boxselection type="SELECT" srow="18" scol="19"
                 erow="18" ecol="51" />
         <pause value="500" />
         <input value="[copy]" row="0" col="0" movecursor="true"
                 xlatehostkeys="true" encrypted="false" />
         <mouseclick row="4" col="15" />
         <input value="[paste]" row="0" col="0" movecursor="true"
                 xlatehostkeys="true" encrypted="false" />
      <nextscreens timeout="0" >