Jump to content
Macro Express Forums

A macro to generate Shortkey macros...


acantor
 Share

Recommended Posts

I have developed a little macro for creating text macros on the fly. It works by automatically generating a new ShortKey macro that types out text.

 

Once triggered (by hotkey), the macro prompts the user for two things: a word or phrase; and the ShortKey associated with that word or phrase. These values are stored as text variables.

 

Then the macro launches the Macro Express editor, and manipulates the user interface to do the following:

 

1. Pick the Category in which to keep the macro.

2. Add a new ShortKey macro.

3. Give it a nickname (based on the ShortKey).

4. Generate the script.

5. Save the new macro.

6. Close the Macro Express editor.

 

This macro is more reliable than it has any right to be, given its complexity. It takes about 5 seconds to generate. The macro works, although I am very aware of all of the ways that it could be made to fail.

 

As a way to increase its reliability, I am wondering whether it is possible to perform the above steps without opening the Macro Express editor. For example, is there a way that I could get Macro Express to write all of the above information to a file, and then import that file?

Link to comment
Share on other sites

I have developed a little macro for creating text macros on the fly. It works by automatically generating a new ShortKey macro

that types out text.

 

Once triggered (by hotkey), the macro prompts the user for two things: a word or phrase; and the ShortKey associated with that

word or phrase. These values are stored as text variables.

 

Then the macro launches the Macro Express editor, and manipulates the user interface to do the following:

 

1. Pick the Category in which to keep the macro.

2. Add a new ShortKey macro.

3. Give it a nickname (based on the ShortKey).

4. Generate the script.

5. Save the new macro.

6. Close the Macro Express editor.

 

This macro is more reliable than it has any right to be, given its complexity. It takes about 5 seconds to generate. The macro

works, although I am very aware of all of the ways that it could be made to fail.

 

As a way to increase its reliability, I am wondering whether it is possible to perform the above steps without opening the Macro

Express editor. For example, is there a way that I could get Macro Express to write all of the above information to a file, and then

import that file?

 

I've built similar macros for my mother-in-law and my wife who both work from home and don't have a programming bone to share

between them, but Macros make their lives so much easier. Their job function is such that they need to create new macros that are

essentially identical to all the others they use, just with different contents, and for sanity reasons (not to mention travel to go to my

in-law's) it made more sense to build a macro that they can run which will gather what is needed for the new job-macro.

 

The only way I've been able to do it, and possibly the only way at all, is to have the macro go through the same steps you would

normally go through manually. I just make sure that they are aware that once they have put in all the information and the macro

is being built, they don't touch anything. In fact, I have a text box pop up asking them not to touch anything until the window

disappears.

 

If there is a way to have a macro be built secretly in the background, I'm not certain it could be done with ME alone. But I'm not

completely positive. Anybody else have any ideas?

Link to comment
Share on other sites

is there a way that I could get Macro Express to write all of the above information to a file, and then import that file?

Only partially. The script portion of a macro can be written to a file. But you still need to use the Macro Express Editor to import from the file and to set the activation (in this case, the shortkey).

 

To see how to create a file containing the script for a macro choose a macro and export it as a playable macro. Playable macros are saved to a file with a .mxe extension and are basically in a text format. You use a text editor (Notepad will work) to look at the content of the resulting .mxe file. Notice that Macro Express uses a special separator character with a value of 01 in specific locations. Your program that creates the external macro file needs to be able to write the separator characters.

 

To determine the syntax for a particular command it is easiest to create an empty macro in the Macro Express Script Editor and then examine it in the Direct Editor. Once you see how a command is structured you can modify it for other purposes (e.g. a Text Type command containing different text).

Link to comment
Share on other sites

Only partially. The script portion of a macro can be written to a file. But you still need to use the Macro Express Editor to import from the file and to set the activation (in this case, the shortkey).

 

Thank you Steve and Kevin for helping me think this through. Steve, I tried your idea of "hiding" the Macro Express user interface behind a text box. (It closes automatically when the script is finished running.) Taking this extra step should go along way toward preventing a user from "accidentally" throwing off the script by typing. And Kevin, it's useful to know what aspects of the macro can be performed by importing a file, and which must be performed by manipulating the user interface. In the end, the code for creating the script portion is only a small part of the whole, so there is no good reason not to do it through the user interface, if it can be done reliably.

 

I appreciate your help.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...