Jump to content
Macro Express Forums

Samrae

Members
  • Posts

    452
  • Joined

  • Last visited

  • Days Won

    22

Posts posted by Samrae

  1. 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.

  2. 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%]%"
        Else
         
          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
          Else
          // 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

  3. 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.

  4. 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

  5. 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.

  6. 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).

  7. 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.

  8. 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
    
  9. 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.

  10. 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.

  11. 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
    
    
  12. PotterHarry: Your macro looks like it was written in Macro Express 3. Is that the case? Are you aware that this is the Macro Express Pro forum and there is a separate forum for Macro Express 3? You will get better help if you post in the correct forum.

     

    I echo Cory's comment. It seems dangerous to write to HKEY_CLASSES_ROOT. That area should be reserved for Windows.

     

    If you want the values to be accessible to only one user, write to the HKEY_CURRENT_USER area of the registry. Perhaps here: HKCU\Software\Macro Express Variables\

    If you want the values to be accessible to every user of a specific computer, write to the HKEY_LOCAL_MACHINE area of the registry. Perhaps here: HKLM\Software\Macro Express Variables\

     

    To help others help you, copy your macro to the clipboard and paste it into a quote box in this forum. To make it even easier, copy your macro using the Command Text menu option and paste it into a another quote box. It will look like this:

    <REGWINT:1:HKEY_CLASSES_ROOT\._A ME VARIABLE_N1><REGRINT:1:HKEY_CLASSES_ROOT\._A ME VARIABLE_N1>

    Write Registry Integer: "._A ME VARIABLE_N1"

    Read Registry Integer: "._A ME VARIABLE_N1"

    Putting macro commands in a quote box allows them to be copied and pasted into our macro files without formatting errors. If the macro appears in the forum text the wrapping and formatting make it difficult to copy and paste.

     

    You can also, as Cory suggested, attach a macro file, either a .mex or .mxe, to your post.

  13. Try something like this:

     

    Variable Modify Decimal: %DecimalOut% = %Decimal1% / %Decimal2% // divide decimal variables
    Variable Modify Decimal: Round %DecimalOut% to 0 decimal places // Round
    Variable Modify Decimal %DecimalOut%: Truncate to Integer (%Integer1%) // Convert to an integer

    You may or may not want to round the decimal value before converting it to an integer. If you do not care about rounding it you can leave out the "Variable Modify Decimal: Round" command.

     

    When trying this out I discovered a bug. When variable names, that do not already exist, are entered into the "Value 1" and "Value 2" fields of the "Variable Modify Decimal: Multiply" command Macro Express Pro only offers to create them as Integer or Large Integer variable types. It should also offer to create them as Decimal variables.

     

    To get around this you can either use the Variables tab to create the variables or you can use "Variable Set Decimal" commands to create the Decimal variables and give them a value. Something like this would work:

     

    Variable Set Decimal %Decimal1% to 29.578
    Variable Set Decimal %Decimal2% to 1.2

    Variable Modify Decimal: %DecimalOut% = %Decimal1% / %Decimal2%
    Variable Modify Decimal: Round %DecimalOut% to 0 decimal places
    Variable Modify Decimal %DecimalOut%: Truncate to Integer (%Integer1%)

     

    I will be reporting this bug to Insight Software.

  14. If you are using a 64-bit version of Windows you will need to use "C:\Program Files (x86)\Macro Express Pro" instead of "C:\Program Files\Macro Express Pro".

     

    Macro Express Pro can have multiple macro files loaded at the same time. The /A command line parameter can be used to specify the macro file along with the macro to run.

     

    This is what worked for me.

     

    Create a batch (runmacro.bat) file containing this:

    "C:\Program Files (x86)\Macro Express Pro\MacExp.exe" /A::c:\Macros\Test4.mex?Test /VT2:Now is the time

    You will need to adjust the path to your macro file (c:\Macros\Test4.mex above). You may need to adjust the path to where Macro Express Pro is installed. As Paul mentioned, you could use meproc.exe instead of MacExp.exe.

     

    Create a macro that looks like this:

    Variable Restore: Restore All Variables

    Text Box Display: Results

    You can copy and paste it from here:

    <VARIABLE RESTORE Option="\x00"/>

    <TEXT BOX DISPLAY Title="Results" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Values from command line: %T[2]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="458" Height="142" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

×
×
  • Create New...