Skip to content

SYMENU System Manager - External Macros

Office Automation

 

Macros

 

Application Overview

 

The Macro was designed for office automation by sending pre-defined keystrokes to the application.  There are two types of macros supported by Elliott: External and Internal.  The external macro is used for controlling applications outside of Elliott, like Word, Excel, etc.  The internal macro is used for controlling Elliott’s applications, like printing an invoice.

External Macros

 

External Macros are used to control applications outside of Elliott which include tasks such as:  generating a letter for a customer, printing labels, dialing a customer’s telephone number, bringing up an image of an item, or any other daily routine that can be accomplished with one of the Windows applications.  With External Macros, the system utilizes the data that is on the Elliott side and utilizes other Windows programs to perform necessary functions.  You can accomplish the same purpose with copy and paste, which is currently supported by Elliott as well.  However, copy and paste may not be fast enough and may require too many steps and keystrokes compared with Macros.

 

Elliott’s External Macro accomplishes office automation by sending data from the current Elliott screen to another Windows application by sending keystrokes and data to that application with a pre-written script.  Once the script is written, it can be used over and over again.  By default, macros are shared by all users.  You can have up to 999 external macros per screen (help-id).

 

For example, you can develop an External Macro that sends a Microsoft Word welcome letter to any new customer that has just been added to your customer database.  To do so, you will first develop the welcome letter in Microsoft Word without the customer name and address.  Save the letter in a file that’s located on the network drive so all users can access it.  Second, you need to develop the script for the Macro that will start Microsoft Word and then bring up the letter that’s stored on the network.  In the Macro, you will send the fields on the customer screen that need to be sent to the letter and place them in the right positions.  Then, all the user has to do is to print out the final letter with the address that comes from the customer.  The macro will greatly reduce the time required to do some of the office routines.  As long as the data is on one of the Elliott screens, and you need the data to be used in another Windows application, Macros can help.  The possibilities are endless.

Internal Macros

 

The Internal Macro is used to automate tasks inside Elliott.  Similar to the external macro, internal macros send key strokes to Elliott applications and automate routine tasks.  The syntax and format for internal macros and external macros are similar, however, not identical.  You can have up to 99 internal macros per screen (help-id).

Defining an External Macro

 

To define a new macro, you will need to click the Macro button (Ctrl-a) on any one of the screens that contain data.  For example, you can click on the Macro button on the Customer Screen when a customer record is displayed on the screen. 

 

 

 

 



Once the Macro function is selected, the following window will display on top of the current screen:

 

 


Only the macros defined for the current screen will display in the list box.  For example, the macros you defined for Customer File Maintenance will not display in the Item File Maintenance screen.  The following is a brief description for the function of each button:

 

 

Run:                 Run the highlighted Macro.

Walk:               Run the highlighted Macro with one second delay between every line of script.

Step:                Run the highlighted Macro in debug mode where users can step through each line of script.

New:                Create a new Macro.

Edit:                 Edit the highlighted Macro.

Delete:             Delete the highlighted Macro.

Cancel:            Exit the Macro Options Screen.

 


At the external tab, click on the “New” button to create a new external Macro, and the following window will display:

 

 

 

 


Title: Enter a title for the Macro you want to create.  The title you entered here will display in the Macro option window.  Therefore, it is important that you do not create duplicate titles among different macros.

 

Application: The name of the application you wish to run, i.e. Winword.exe.  If you do not know the exact spelling of your application, you may click the browse button to explore your hard drive and find your application. 

 

A special application, START, can be used to launch a document file (any file that has an associated application for it).  In this case, enter the document name (file name or http: address) as the only line in the [Script] section of the macro file.

 

Browse: To find the application, if you do not know the exact spelling.  Alternatively, if you do not know the path for your application, you can use browse to find it as well.

 

Caption: Unless Macro has problems communicating with the Windows application you try to run, you should always leave this field blank.  When you first try to write a Macro, it is suggested to leave it blank.

 

Hint for Caption: Clicking on this button will give you a hint for entering the caption if you need to (when Macro fails to communicate with your application).  For example, if you are using Microsoft Word 6.0, the startup application is Winword.exe.  However, once Winword.exe starts, it calls another EXE for the Microsoft Word main process and Winword.exe will terminate itself.  Therefore, the macro will not be able to communicate with Winword.exe. 

 

In this case, you need to specify the caption as “Microsoft Word” so the macro can communicate with Microsoft Word even though the startup application EXE has terminated itself.  This, however, is not a problem with Office 97.

 

Directory:  If you chose the browse button earlier, the right directory should have been returned back to this field.  Otherwise, enter the directory where your Windows application resides.

 

Hot Key: You can assign a hot key with combination of the Alternate key, (Alt), and 26 alphabetic characters from A – Z to execute a macro.  For this reason, you can only have maximum 26 macros that can be assigned with a hot key.  Hot key speeds up the process of a macro since you do not have to pick and choose from the macro list box.  This is an optional function.

 


Return Focus When Finished:  By default, leave the check box off.  In most situations, when you finish executing your macro, you want to leave the focus in the Windows application you try to run.  For example, if you try to send a welcome letter to your customer, you may want to leave the focus in Microsoft Word and let the user choose which printer to print to.  However, if you wrote the macro so that the printing is automatically done in Microsoft Word, then you might want to check this field and return to Elliott after the macro finishes the executing.

 

Description: Five lines of free format for you to enter the detailed description for the macro.

 

Once you finish entering each field and click on the OK button, a floating window will pop up on top of your current screen:



 

 

  

At this moment, the focus is back on the Elliott screen where you invoked the Macro function.  What you need to do now is decide which fields on this screen are needed for your letter.  For example, you may need the Customer Corresp Name on the letter.  Therefore, you will put your cursor on field 3, Corresp Name, by either using the mouse or entering “3” when prompte for Field Number. 

 

When the cursor is on field 3, the “Add Field” button on the floating window will be enabled.  By clicking on the “Add Field” button, the following window will display:

 


 


The system will determine the field name, the position and length of the field automatically.  In most situations, you will not need to do anything on this screen, just click the OK button to accept the default value.  Repeat this step for all the fields you want on the letter.  For example, you will want Address-1, Address-2, City, State, Zip Code, and Contact to complete a letter address portion.  Repeat this step for these fields.

 

Now you are ready to write the actual script for the macro.  Click on the “Script” button on the floating window, a notepad with the macro we have created this far is displayed.  At the end of the macro, you will find a section starting with [SCRIPT] that is currently empty.  The following is the sample script:

 


Notice that the fields you added earlier through the interactive user interface are in the macro as well.  You can manually add these fields if you want to, provided you know the position and length of each field on the screen you try to capture.  At this moment, Elliott has just created a skeleton of a macro where it contains the Macro Name, Application Name, Field Names and Position, etc.  It does not contain the actual keystrokes that you wish to send to the other software application.  It is your responsibility to write the script now. 

 

The script you need to write will contain the actual keystrokes that you need to send to the Windows application.  In this case, it is Microsoft Word.  When the first keystroke is sent to Microsoft Word, the Microsoft Word application has been brought up already and it is in focus.  Typically, you need to ask Microsoft Word to open a file for you.  You will do so by sending two lines of script:

 

            %fo

            c:\nsi\welcome.doc{enter}

 

“%f” means Alt-f which will bring down the file menu in Microsoft Word.  “o” means open a file on the file menu.  Therefore, the file open dialog will display and the cursor is at the file name field. 

 

If you send over the path and the file name, followed by an enter key, then this will open welcome.doc in Microsoft Word.  At this moment, your screen may look like the following:

  

 

 

Since your cursor is at the beginning of the document, you need to move your cursor down before sending over the actual address information.  Therefore, you’ll need to write the following lines of script:

 

            {down 4}

            Attn: @@Contact@@{enter}

@@Corresp-Name@@{enter}

            @@Address-1@@  @@Address-2@@{enter}

            @@City@@, @@State@@ @@Zip-Code@@{enter}

 

{down 4} means press the down arrow key 4 times which will bring it to the correct position to populate the address information.

 

@@Contact@@ means send over the actual contents in the “Contact” field.  Anything beginning with “@@” and ending with “@@” is the field name.  You can have multiple fields per line and they can be combined with other characters.  We put Address-1 and Address-2 in the same line because many times, address-2 is blank and we do not want to waste a blank line.  Words like “Attn:” will be sent over to Microsoft Word as is.  At the end, your script will look similar to the following screen:

 

 

 

 

If you would like to display the print dialog window so the only thing users have to do is select or confirm the printer, then you can add the following line at the end of the script:

 

            %fp

 

Where “%f” means Alt-f and will bring up the file menu and “p” means “Print”.

 

At this moment, if you save your script and exit notepad, you will be back at the Elliott screen.  Click the “Done” button on the floating window.  Now you have finished defining the macro and you are ready to run it.

 

Click on the “Macro” button (or use Ctrl-a), the macro option window will be displayed and you will see the macro you just created.  Highlight the macro you just created and click on the “Run” button.  You should see the following result:


 



If your script does not produce desirable results, it is possible there is a problem in your script.  You can use the “Step” method to let the system confirm every single line of the script before it sends it over to the Windows application.  You will then see exactly the position where your script fails and you can then determine the measure to fix your problem.

 

Syntax for External Macro Script:

 

Execute a Special Command:  Any line beginning with && indicates whatever follows on this line is either a DOS, or a special command to be executed.  The following are some special commands:

 

&&Wait n – Wait for number of seconds.  When the system does not respond fast enough with certain steps and you can see the keystroke it is sending before the system can respond to it, there’s a possibility of losing keystrokes.  You might want to consider using this command to delay the sending of keystrokes.  For example, &&Wait 1 means wait 1 second before sending the next line or keystroke.  Alternatively, if the run method seems to lose keystrokes, you can try the “Walk” method, which delays 1 second between every line.  If you omit the number of seconds, the script will use 1 second by default.

 

&& Wait Close – Use for waiting for a dialog box window to close before sending the next keystroke.  This should only be used if you have a problem with your Macro sending the script faster than it is closing the window.

 

&&Dos Command - In the above example, you may want to save the original document in the welcome.tbl file and copy it to the welcome.doc file after you execute this script.  This is a safety precaution just in case users accidentally override the welcome.doc file.  You can only have one DOS command per line.  Do not try to put multiple && on the same line to execute multiple DOS commands.

 

Sending a Field: @@field Name@@ means send the information in this field to the Windows application.  No trailing spaces will be sent.  This is the same field name that was defined earlier.  You can have multiple fields on the same line.  You can also mix fields with regular text.

 

Putting Comments in a Script – “;;” means that whatever follows after until the end of the line is a comment and will not be sent to the Windows application software.  “;;” can begin anywhere, even in the middle of the line.  Anything before “;;” will still be processed normally.

 


Other special symbols:

Character                      - send the character

{{}                                             - send the { character

{}}                                             - send the } character

{+}                                            - send the + character

{^}                                             - send the ^ character

{%}                                           - send the % character

{char number}    - send the character number of times

+                                              - next character (or set in parens) is SHIFT

^                                               - next character (or set in parens) is CONTROL

%                                             - next character (or set in parens) is ALT

(chars)                          - group of characters (can all be shift/control/alt)

{backspace} or {bs} or {bksp}

{break}

{capslock}

{clear}

{delete} or {del}

{down}

{enter} or ~

{escape} or {esc}

{help}

{home}

{insert}

{left}

{numlock}

{pgdn}

{pgup}

{prtsc}

{right}

{scrollock}

{tab}

{up}

{f1} {f2}{f3} {f4}{f5} {f6} {f7} {f8} {f9} {f10}

{f11} {f12} {f13} {f14} {f15}

 

Sample strings:

            +(EC)                Uppercase E then C

            +EC                  Ec

            {X 10}                XXXXXXXXXX

            %fo                   Alt-f then o (as in File Open) 

            {left 42}             Press left arrow 42 times

 

Sample Scripts:

 

&& copy f:\users\public\welcome.tbl f:\users\public\welcome.doc

            %fo    ;;Alt-F for file menu, choose open a file

            f:\users\public\welcome.doc{enter}    ;;type in the file name and hit the

;;enter key

            &&Wait Close    ;;waiting for the file open dialog to close before

;;sending the keystroke

            {down 5}   ;;press the down arrow key 5 times

            Attn: @@Contact@@{down}   ;;@@Contact@@ indicates the field

;;name just created

            @@Corresp-Name@@{down}

            @@Address-1@@   @Address-2@@{down}

            @@City@@, @@State@@ @@Zip-Code@@{down}

            @@Country@@

            %fp{enter}    ;;Alt-F for file menu, choose to print and press enter to

;;choose the default printer

            %fxn   ;; Alt-F for file menu, choose exit and do not save the change

 

In the above example, the first line will copy welcome.tbl to welcome.doc and the third line will use welcome.doc as the letter file.  This may be beneficial if you do not want your users to accidentally override the original document when exiting Microsoft Word.


Writing and Testing Your External Macro Script

 

Writing the script:  The best way to write the macro script is to start the application software and try to find the keystrokes that are needed to perform the process you need, step by step.  Then you can write the keystrokes in the script.  Any time you need to send a combination key like %f (Alt-f), make sure you use the lower case “f”.  %F will be interpreted by the system as (Alt-Shift-f) and will not produce desirable results.

 

Captions:  In most situations, you should leave Captions blank.  The only time you may need to put something in the Captions field is when your Macro seems to fail to communicate with the Windows application you try to run.  This may happen, for example, with Microsoft WinWord 6.0.  WinWord 6.0 starts up with Winword.exe and calls another EXE for the main process, then terminates itself.  Therefore, when the Macro tries to communicate with Winword.exe, since it has been purged from memory, nothing will happen.  In this situation, you need to put the caption, “Microsoft Word” (as in the WinWord title bar) for Macro to establish the communication.

 

If you need to put something in the caption in order for your Windows applications to work, the rule for determining the caption is to bring up your Windows application first and see what displays in the title bar.  For example; when you start WinWord 6.0, by default the title bar is “Microsoft Word – Document1”.  Here you should not use “Document1” as part of the Caption because that is not always part of the Caption for WinWord 6.0.  In this case, using “Microsoft Word” is sufficient because the Macro will match with the prefix.

 

If a caption is entered when it is unnecessary, then you may get unexpected results.  Lets use, NOTEPAD in Windows 3.1, for example.  When NOTEPAD is executed it will have “Notepad – (Untitled)” in the title bar.  If you enter “Notepad” as the caption, then it will work fine in the Windows 3.1 environment.  However, in Windows 95/98, NOTEPAD uses “Untitled – Notepad” as the caption.  The caption that works for Windows 3.1 Notepad will not work for Windows 95/98’s Notepad.  In both situations, if you leave the captions blank, the system will function correctly.  Therefore, you are better off leaving the caption blank if the Macro works.  There is no rule to predetermine whether captions are needed or not with certain Windows applications.  Users simply have to test each application.

 

Test the script:  You may need to test and revise the script a couple of times before you achieve the final desirable results.  Please be aware that different users may have different setups for their application programs and therefore, the same keystrokes that work for one user may not work for another.  You need to take this into consideration and define keystrokes that will work for everybody. 

 


Test the script with animation mode:  The best way to test a script for problems is to execute the script in animation mode and choose the time delay for each line.  Users can set the time delay anywhere between 1 and 99 seconds.  This is done at the time of executing the Macro.  In the Macro window, there is a checkmark where users can set the execution to animation mode and the “time delay field” will become available.  Each statement will first be displayed and users will see the result of execution.  At any moment, if you wish to stop the execution, choose “Stop” or “Edit”.  “Edit” will start your favorite editor for the script you are currently executing and you can make changes if you have discovered any mistakes.

 

Running the Macro: Once a macro has been defined, you can run this macro over and over.  In our example, a new customer is added into the system and the user only has to click on the macro button, choose “New Customer Welcome Letter” and the letter will automatically be printed.  This will be a great time saving tool.  Just use your imagination.  You will find that there will be many applications to use with this feature to save you significant amounts of processing time.

 

Make Your Macros Private:  You can specify a different macro directory for each user in the preference setup.  By default, the system uses the Macro subdirectory of the Elliott startup path (i.e. \ELLIOTT\MACRO) as the default macro path for all users.  This means that macros will be shared by all users.  However, you may change this if you have the following concerns: (1) security issues – you may not want to let users run all macros in the system,  (2) compatibility issues – a macro written for one workstation may not work for another because (a) not all workstations have the same applications installed and (b) not all of them are installed in the same directory.  In this case, you can simply designate a different macro path for each user.

 

Use A Different Editor for Macro Editing:  By default, the system will use NOTEPAD as the editor for your Macro script.  However, you can choose to use your favorite editor by changing the default setting in the preference setup.  You should be aware that by changing your default editor, it also changes the default viewer for your spooled reports.

 

 

Tips for Speeding up Macro Execution:  You can use “&&Turbo On” to speed up the execution of Macro.  Another technique is to combine multiple lines of script into one single line to avoid the delay between each line.  Just keep in mind that the maximum length for a script line is 255 characters.  For example, you can change the following script:

 

            {down 4}

            Attn: @@Contact@@{enter}

            @@Corresp-Name@@{enter}

 

To:

            {down 4}Attn: @@Contact@@{enter}@@Corresp-Name@@{enter}

 

The system will process the script as one request instead of three requests and thus speed up the performance.

 

Feedback and Knowledge Base