Macro Activation

 

Below is a chart listing the available options for activating a macro.

 

 

Activation

Description

Hot Key

A hot key is a key combination such as CTRL+ALT+A, CTRL+Right Mouse Click, etc. The macro activates when the keys are pressed and released.

Shortkey

A shortkey is a set of characters such as abc, myname, etc. The macro activates when the keys are typed into an application.

Schedule

The macro runs as a scheduled event. These events can be scheduled to play at startup of Macro Express, hourly, daily (choose any or all days of the week), weekly, monthly, one given time, every "x" minutes or after "x" minutes of inactivity.

Window Title

This option looks for a specific window title. The macro activates when the window either gains focus, loses focus, opens or closes, depending on the option selected.

Mouse Event

Use either the left, middle or right mouse buttons to activate the macro. Select an area of the screen to click on or designate a window part to click on, such as scroll bar, title bar, buttons, etc. to activate the macro.

Control Event

The Control Event option activates a macro when a specific Windows control or the window that contains the control gains focus. The control may be a window button, edit box or another identifiable portion of a window.

Floating Menu

A Floating Menu is a menu of macros displayed as a floating tool bar and sits on top of other open applications. The floating menu either displays icons (representing the macros), the first part of the text of the macro or the macro nickname and scope. Clicking on one of the macros or typing a corresponding number or letter activates that macro from the floating menu.

No Activation

No Activation indicates that there is not an activation associated with the macro. In such cases, the macro may be included as a subroutine of another macro using the Macro Run command. Or the macro may be used in a popup menu of macros and no other macro activation is desired for the macro.

Popup Menu

A popup menu of macros is a list of macros displayed in a window. Clicking on one of the macros or typing a corresponding number or letter activates that macro from the popup menu. The popup menu itself is activated by either a hot key or by right clicking on a notification area icon. The popup menu may show icons (representing the macros), the first part of the text of the macro or the macro nickname and scope.

Command Line Parameters

Invoke a macro using a command line parameter. The specific command line parameters to invoke a macro are the /A and /MXE commands. Both the macexp.exe and the meproc.exe programs may be used. See the command line parameters help section for more detail.

Windows Explorer / File Explorer

Double clicking on a playable macro file (.MXE) from within Windows Explorer/File Explorer executes the macro.

Run Macro Now

Run a macro from the Macro Express - Explorer by using the Run Macro Now option. Right click on the macro in the Macro Explorer and then left click on the Run Macro Now menu item. Or highlight the macro in the Macro Explorer list and click on the Run Now button.

Windows API Calls

This option is only intended for the programmer who wants to add macro functionality directly from their own programs. While the command line parameter options can be used via another program, the following method may be much quicker and remove the overhead of having to run an external program such as macexp.exe or meproc.exe.

 

Instruct the Macro Express Player to directly execute a macro in the currently loaded macro file by specifying its nickname or instruct it to run a playable macro. The macro nickname is case sensitive. If more than one macro shares the same nickname, only the first one found in the macro file is activated.

 

 

 

Windows API examples

The following examples demonstrate the basic steps of how to activate a macro using Windows API messages and are presented in several different programming languages. These examples assume familiarity with basic Windows API commands and terminology. The process involves posting a series of messages directly to the Macro Express Player.

 

These examples use the message WM_USER+20 to run a macro within the currently loaded macro file. To run a playable macro, change the messages in the examples from WM_USER+20 to WM_USER+21.

 

 

 

Delphi Example

 

var

  i     : integer;

  S    : string;

  Hwnd  : THandle;

begin

  Hwnd := FindWindow('TMainWin', 'Macro Express Player');

  if(IsWindow(Hwnd)) then

  begin

    S := MacroName;

 

    for i := 1 to length(S) do

      PostMessage(Hwnd, WM_USER+20, ord(S[i]), 0);

    PostMessage(Hwnd, WM_USER+20, 0, 0);

  end

  else

    ShowMessage('Macro Express is not running');

end;
 

 

 

 

C/C++/Visual C Example

 

HWND hwnd = FindWindow("TMainWin", "Macro Express Player");

if( IsWindow(hwnd) ) {

  for(int x = 0; x < strlen(s); x ++)

    PostMessage(hwnd, WM_USER+20, s[i], 0);

  PostMessage(hwnd, WM_USER+20, 0, 0);

}

else

  MessageBox(GetForegroundWindow(), "Macro Express is not running", "Error", 0);
 

 

 

 

VBA Example

 

HWND hwnd = FindWindow("TMainWin", "Macro Express Player");

if( IsWindow(hwnd) ) {

  for(int x = 0; x < strlen(s); x ++)

    PostMessage(hwnd, WM_USER+20, s[i], 0);

  PostMessage(hwnd, WM_USER+20, 0, 0);

}

else

  MessageBox(GetForegroundWindow(), "Macro Express is not running", "Error", 0);
 

 

Private Declare Function FindWindow _

  Lib "User32" Alias "FindWindowA" ( _

       ByVal lpClassName As String, _

       ByVal lpWindowName As String) As Long

         

Private Declare Function PostMessage _

  Lib "User32" Alias "Porterage" ( _

       ByVal Wand As Long, _

       ByVal MSG As Long, _

       ByVal warm As Long, _

       ByVal Parma As Long) As Long

 

Private Sub Unsacred)

  'Runs a macro express macro

 

  Const WM_USER = &H400

  Const Command = WM_USER+20

  Const Macroname = "Macroname"

 

  Dim hwnd, I, Result As Long

 

  hwnd = FindWindow("TMainWin", "Macro Express Player")

  For I = 1 To Len(Macroname)

    Result = PostMessage(hwnd, Command, Asc(Mid(Macroname, I, 1)), 0)

  Next I

  Result = PostMessage(hwnd, Command, 0, 0)

End Sub