Jump to content
Macro Express Forums


  • Content Count

  • Joined

  • Last visited

  • Days Won


Posts posted by Samrae

  1. In my experience some programs have consistent Window Controls. Others, however, create a new Window Control every time the program runs. I happen to have macros that interact with a program somewhere in the middle. Most of the time the Window Control is consistent but sometimes it changes.


    To get around this, when my macro interacting with this program has a problem with the Window Control I add the new Window Control to my macro. It looks like this:

    Get Control: (CLIENT.EXE) Using z-order -> %Description% // Description box  6-13-12
    If Control "%Description%" Does Not Exist
      Get Control: (CLIENT.EXE) Using z-order -> %Description% // Description box
    End If
    If Control "%Description%" Does Not Exist
      Get Control: (CLIENT.EXE) Using z-order -> %Description% // Description box  7-8-11
    End If

    Fortunately, there seems to be a limited number of Window Controls for this element. So a check for three different Window Controls works.


    I do not know whether any specific one of the different ways of identifying a Window Control is more or less reliable. I usually try the default (z-order) value first. If that does not work I will try the next (contents) and if that doesn't work then the last choice (coordinates).


    The Capture Control command requires that you know the X/Y position of an element but the Window Control for that element works correctly until the program is restarted.

  2. Instead of doing this at the end of the macro I would do it using two macros.


    Create your main macro. Let's call it MainMacro.


    Create a second macro that looks like this:

    Variable Set String %T1% "Yes"
    Repeat Until %T1% <> "Yes"
      Macro Run: MainMacro
      // Ask the user if they want to continue
      Variable Set String %T1% from Prompt
    Repeat End

    I did not test this sample. You may need to adjust it but this should get you started.

  3. The 'Macro Playback Speed' has the effect of adjusting all the delays in your macro. Entering 0.1 in the 'Playback Factor:' has the effect of speeding up the macro by 10 times. All delays of 500ms run at 50ms.


    You could do a bulk replace in the Direct Editor. Do this to change all 'Delay 10 Milliseconds' command to 'Delay 1 Milliseconds':

    1. Click the Direct Editor button
    2. Click at the beginning of the macro
    3. Press Ctrl+R to bring up the Find/Replace dialog
    4. Enter <MSD:0010> in the 'Find what:' field
    5. Enter <MSD:0001> in the 'Replace with:' field
    6. Click the Replace All button

    To remove all 10ms delays search for '<MSD:0010><' and replace it with '<'.


    When I create a macro that I am going to use more that a few times I spend some time to optimize it. One thing that I do is to use variables for the delays.

    Variable Set Decimal %D1% to 0.025
    Variable Set Decimal %D2% to 0.1
    Variable Set Decimal %D3% to 1.0
    // Some macro commands
    // Short delay
    Delay %D1% Seconds
    // Some more macro commands
    // Medium delay
    Delay %D2% Seconds
    // Even macro commands
    // Long delay
    Delay %D3% Seconds

    Then, if I need to change the delays I only need to change them at the top of the macro.

  4. Here is a sample macro that may get you started. (Download this macro by clicking on the filename below.)

    // -----------------------------------
    //   Make choices
    // -----------------------------------
    Multiple Choice Menu: Symptoms
    Clear Variables // Clear the variable array, just in case the Symptoms variable is reused
    Split String "%Symptoms%" on ", " into %SymptomArray%, starting at 1 // Split each choice into a separate element of an array variable
    // Loop through each element of the array variable and assemble the output into the Symptoms2 variable
    Repeat Start (Repeat 50 times)
      Variable Set Integer %IdxPlus1% to %Idx%
      Variable Modify Integer %IdxPlus1%: Increment
      If Variable %SymptomArray[%Idx%]% Does not Equal "" // If this element of the array is not empty
        If Variable %Symptoms2% Equals "" // Is Symptoms2 empty?
          Variable Set String %Symptoms2% to "%SymptomArray[%Idx%]%"
          If Variable %SymptomArray[%IdxPlus1%]% Equals "" // If the next element is blank we know the current element is the last one
          // Handle the last item
            Variable Set String %Symptoms2% to "%Symptoms2% and %SymptomArray[%Idx%]%"
            Repeat Exit // Last item processed, exit the repeat loop
          // Add this item to the list
            Variable Set String %Symptoms2% to "%Symptoms2%, %SymptomArray[%Idx%]%"
          End If
        End If
      End If
    End Repeat
    // -----------------------------------
    //   Display result
    // -----------------------------------
    Text Box Display: Result

    Sample-Multiple Choice And.mex

  5. If I assign a hotkey (any of several) to this particular macro, and set Scope so that MacExp.exe must be on top (which of course it is when I have just selected a macro in Explorer) then nothing happens. No activation.

    MacExp.exe is the process for the Macro Express Pro - Player.

    MacEdit.exe is the process for Macro Express Pro - Explorer.

    MacScript.exe is the process for the Macro Express Pro - Script Editor.


    If you are setting the scope of a macro to only run when MacExp.exe is on top it will never run. This process is always hidden. It can never be on top or have focus.


    Try setting the scope to MacEdit.exe or MacScript.exe depending on which process your macro is written for.

  6. how is it possible to react if someone presses the cancel button e.g. on a multiple choice menu.

    There are a few ways to do this. Here is what I suggest:

    Variable Set String %Choice% to "CANCEL" // Set a default value for the Choice variable used in the Multiple Choice Menu command
    Multiple Choice Menu: Choose something // use %Choice% for the Destination Variable
    If Variable %Choice% Equals "CANCEL"
    // The CANCEL button was clicked
    End If
    If Variable %Choice% Equals "A"
    // Option A was chosen
    End If
    If Variable %Choice% Equals "B"
    // Option B was chosen
    End If

    In the On Error tab of the Multiple Choice Menu command look for "The dialog was cancelled" and choose "Ignore Error".


    Of course you will need to change the If statements if you use the "Save Item Text" and/or "Multiple Choice" options in the Multiple Choice Menu command

  7. I do alot of tabbing between the favorite/line code area, is there a way I can get the short keys for this?

    Use Alt+Left Arrow to move to the Favorite Commands / Code Snippets / All Commands pane (depending on which is selected)

    Use Alt+Right Arrow to move to the Script area (line code area)

    Use Alt+Down Arrow to move to the Search for Command box


    For example i want a shortkey for that green arrow to bring a command from the left side to the right side

    Once you highlight a command on the left, if you press the ENTER key it is inserted on the right side (the script area). You can choose where the commands are inserted by clicking Options and choosing "Insert Command Before Selected", "Insert Command After Selected" or "Add Command to End of Script".


    Also how do i modify established snippets?

    The way I do this is to open a new, blank macro in the Script Editor, click Snippets, click on the snippet to put it in the script area, edit it, highlight it and save it as a Snippet.


    Also is there an easier way to add something to favorites instead of ... OPTIONS.... customize favorites...?

    I am not aware of another way to do this.


    When writing macros I use the Search box extensively. For example, when I want a Text Box Display command I press Alt+Down Arrow, "text box d" and ENTER. I don't always type the entire thing. I may type "tex" and Down Arrow and then ENTER. I do not use Favorite Commands because I can search for my favorite commands so quickly.

  8. To clarify, that is the Notification Area of the Taskbar. Microsoft changed the name of this area. It was formerly known as the System Tray.


    To access programs in the Notification Area / System Tray you can use the "Move Mouse to Tray Icon" command. After the mouse is moved you can right-click or left-click the mouse to activate the menu associated with that icon. Note, however, that the "Move Mouse to Tray Icon" command does not work with icons that are hidden by Windows. To get around this Windows allows you to select which icons are hidden (although I have had mixed results with this).

  9. The sample macros (samples.mex) contain a list of variables that are used in remarks at the top of the macro. For example:

    // Variables used:
    //   T1  - Selection made in Multiple Choice Menu command
    //   T2  - A message for the Text Box Display command
    //   T3  - Windows version selected in Multiple Choice Menu

    It is a little bit of work to do but a list like this sure helps when you edit the macro in the future.


    I like the named variables in Macro Express Pro. It makes knowing which variables that are used a lot easier. It also makes it less necessary to know what variables are used.

  10. Here are two more to consider along with Alan's great suggestions:


    6. Change the size of the browser window to allow reliable positioning of elements in the browser. Then use mouse clicks on known locations. If necessary, you can save the size of the window at the top of the macro and restore it at the end.


    7. Alan mentioned using <SHIFT><TAB> (back tab). I have found that in some cases this can be more reliable rather than tabbing forward through the fields in the browser window. Something like this:

    Text Type: <ALTD>d<ALTU>  // Move to the address field of the browser
    Repeat Start (Repeat 44 times)
      Text Type: <SHIFTD><TAB><SHIFTU>  // back tab
    Repeat End
  11. Is there a way for me to use a virtual machine that would help in this scenario, where I could lock the PC but expand my use of macro express by running a local VM session?

    On a VMWare virtual machine running Macro Express Pro I created a macro that writes to a log file every second. When the VMWare session was minimized, the macro kept running. When I logged off of my workstation the macro kept running in the VM. It looks to me like it will do exactly what you trying to do.


    Note, however, that since the VM is like a separate computer, you would have to install MS Access on it to have it continue to process things. Macros running on the VM do not automate programs or tasks on your host computer.

  12. After your macro performs a Get Control command you can follow it with one of these commands.

    If Control %C1% Focused
    If Not Control %C1% Focused
    If Control %C1% Visible
    If Not Control %C1% Visible
    If Control %C1% Enabled
    If Not Control %C1% Enabled

    Macro Express Pro contains additional options:

    If Control "%cDialog%" Exists
    If Control "%cDialog%" Does Not Exist
    If Control "%cDialog%" is visible
    If Control "%cDialog%" is not visible
    If Control "%cDialog%" is focused
    If Control "%cDialog%" is not focused
    If Control "%cDialog%" is enabled
    If Control "%cDialog%" is disabled

    Note that not all of these commands work for every control. It depends on how the program you are automating works.

  13. There are macro commands to copy to and from the clipboard. Try something like this:

    Variable Set String %Temp% to "This is a test."
    Variable Modify String: Save %Temp% to the clipboard

    The Text Type command has an option to "Use Clipboard and Paste Text". By default this is set to "Simulate Keystrokes". Using this option you don't even need to use the Variable Modify String command.


    Sometimes I want to keep the text on the clipboard so I have my macro save and restore it, like this:

    Variable Set String %ClipboardSave% from the clipboard contents // Save the content of the clipboard
    Variable Set String %Temp% to "This is a test."
    Variable Modify String: Save %Temp% to the clipboard
    Variable Modify String: Save %ClipboardSave% to the clipboard // Restore the content of the clipboard
  • Create New...