Copy and Paste Between Two Applications

 

Below is a simple example of how to set up a copy and paste routine between two applications. Use this as a guideline for creating routines between other applications.

 

You might be tempted to try and use the ALT+TAB key to switch between programs. This is actually not always reliable and in fact will not even work via Macro Express on some computers due to the low level nature of this key command. The solution is to use the Windows Activate command.

 

 

Setting up the Macro

Choose a HotKey and macro Scope.

 

1.From the Macro Express Pro - Explorer menu click on Macro > New Macro to open a Create New Macro window.

2.The Initial Activation should default to HotKey.

3.Click on the HotKey edit box to place the cursor in this field.

4.Hold down the CTRL key, the SHIFT key and the P key all at the same time and release them.

5.CTRL+SHIFT+P should appear in the edit box.
This is the hot key used to activate the macro.

6.Enter Copy and Paste in the Nickname field and click OK to open the Script Editor.

7.Click on the Scope tab and make sure that the macro scope is set to global.

8.Then click on the Script tab to start building the macro.

 

 

Building the Macro in the Script Editor
The object of the macro is to repetitively copy one line at a time over to WordPad.
 

1.This first command instructs the macro to bring notepad to the front and be ready to receive keystrokes.

a.  Scroll through the list of command categories and click on Windows/Programs to expand the list.
b.  Double click on the Window Activate command.
c.  In the Activate Window field, enter "notepad" (without the quotes) as the Window title.
d.  Make sure the Partial Match option is selected. Click on the OK button to save the entry.

 

2.The next step in this process is to highlight a single line of text byusing Shift+End.

a.  To do this scroll through the list of command categories and click on Keyboard to expand the category.
b.  Double click on Text Type to open the Text Type window.
c.  Click on Shift and then End in the yellow area of this window to insert <SHIFT><END> into the Keystrokes edit field.
d.  Click OK to save the changes.

 

3.The next step is to copy the highlighted text to the Windows Clipboard.

a.  Scroll through the list of command categories and click on Clipboard to expand the category.
b.  Double click on the Clipboard Copy command to insert into the script.

 

4.Before pasting the text into WordPad, we will first move the cursor to the next line in notepad so that the macro is ready to copy the next line of text.

a.  To do this, scroll through the list of command categories and click on Keyboard to expand the category.
b.  Then double click on Text Type to open the Text Type window.
c.  Click on Home and then Arrow Down in the yellow area of this window to insert <HOME><ARROW DOWN> into the Keystrokes edit field.
d.  Click OK to save the changes.

 

5.This step activates WordPad and allows text entry into this window.

a.  To activate WordPad, click on the Windows/Programs category of commands to expand the list.
b.  Double click on the Window Activate command.
c.  In the Activate Window field, enter "wordpad" (without the quotes) as the Window title. 
d.  Make sure the Partial Match option is selected.
e.  Click on the OK button to save the entry.

 

6.The next step of the macro is to paste the text from the clipboard into WordPad.

a.  Scroll through the list of command categories and click on Clipboard to expand the category.
b.  Double click on the Clipboard Paste command to insert into the script.

 

7.Now place an <ENTER> in the macro to move the cursor to a new line in WordPad.

a.  Scroll through the list of command categories and click on Keyboard to expand the category.
b.  Double click on Text Type to open the Text Type window.
c.  Click on Enter in the list of options in the yellow area of this window to insert <ENTER> into the Keystrokes edit field.
d.  Click OK to save the changes.

 

8.Two final issues need to be addressed. The first is to place the macro in a loop so that it copies multiple lines. In this example we will set the macro to copy the first 5 lines in notepad over to WordPad.

a.  Highlight the first line of the macro script - Activate Window: "notepad".
b.  Scroll through the list of command categories and click on Repeat to expand the category.
c.  Single click on the Repeat Start option and then click on the Insert Command Before Selected arrow - the top green arrow of the three insert arrows to open the Repeat Options window.
d.  Make sure the Repeat Start option is selected and enter 5 in the Number of Times to Repeat entry field.
e.  Click OK to save the change and insert the Repeat command as the first line of the macro.

 

9.This step closes the repeat loop.

a.  Single click on the End Repeat command
b.  Click on the Add Command to End of Script button - the bottom of the three Insert buttons to insert an End Repeat command as the last command of the macro script.

 

10.The last thing is to address a possible timing issue. It's possible for Macro Express to send the Clipboard Paste command before WordPad has fully activated. So what we need to do is insert a short delay right after activating either window.

a. Add a Delay command to the script.
          1)  Scroll through the list of command categories and click on Timing to expand the list.
          2)  Then double click on Delay to open the Set Delay window.
          3)  Select the Delay in Seconds option and enter .5 (one half second).
          4)  Click OK to save the change.

b. Make a duplicate of the Delay command
          1)  Find the delay command we just created in the script and highlight it.
          2)  Then click on the Duplicate button  to the right of the script to make a copy of this command.

You should now have two Delay commands listed in the script.

c.  Positioning the Delay commands in the script.
          1)  Highlight one of the Delay commands and click on the Up or Down arrow on the right side of the Macro Script.
          2)  Move the delay command so that it is positioned below the Activate Window: "notepad" command and above the Text Type:<SHIFT><END> command.
          3) Highlight the other Delay command and move it so that it is positioned below the Activate Window: "wordpad" command and above the Clipboard Paste command.

 

11.Click on File > Save to save the macro.

 

 

Macro Script

The macro script should look like what is displayed below. If the macro does not look like this, arrange the commands so that they are in the following order.

 

Repeat Start (Repeat 5 times)

  Window Activate: notepad

  Delay: 0.5 seconds

  Text Type (Simulate Keystrokes): <SHIFT><END>

  Clipboard Copy

  Text Type (Simulate Keystrokes): <HOME><ARROW DOWN>

  Window Activate: wordpad

  Delay: 0.5 seconds

  Clipboard Paste

  Text Type (Simulate Keystrokes): <ENTER>

End Repeat

 

 

Testing the Macro
 

1.To test the macro run the notepad and WordPad applications. 

2.Enter five lines of text into notepad or copy the first five lines of the macro script displayed above and paste them into notepad.

3.Make sure you don't have any blank lines between the lines of text.

4.Next, place the mouse cursor at the beginning of the first line of text in notepad.

5.Then press CTRL + Shift + P to start the macro and watch it switch between both programs, copying each line from notepad and pasting into WordPad.