Jump to content
Macro Express Forums


  • Content Count

  • Joined

  • Last visited

  • Days Won


Posts posted by Samrae

  1. AtinK: You could use the Windows Task Scheduler to run a macro. When you define a task in the scheduler you can specify that it needs to log in to perform the task. For the process you can either specifiy the Macro Express Player (macexp.exe) or the smaller launcher (meproc.exe) and use a parameter that looks something like "/AYourMacro".

    Cory: After reading your critique of AtinK's macro I decided to look at it. For anyone else interested, here it is in human readable form:

    If Program "XYZ" is running
      Terminate Process: XYZ
    End If
    Delay: 5 seconds
    Launch Program and Activate Window: Program "XYZ.exe", Parameters "", Window "XYZ"
    If Not Program "XYZ.EXE" is focused
      Window Activate: XYZ
    End If
    Window Activate: XYZ
    Delay: 3 seconds
    Text Type (Simulate Keystrokes): username
    Delay: 2 seconds
    Text Type (Simulate Keystrokes): <TAB>
    Delay: 2 seconds
    Text Type (Simulate Keystrokes): password
    Delay: 2 seconds

    Cory, I rarely disagree with your analysis but in this case ...


    AtinK, The only change I would make is to remove the second "Window Activate" command. That one IS unnecessary. The remainder of the macro I would leave as is until I was certain that it worked. This macro looks just like how I would write it before optimization. Once the macro is working you can either reduce the amount of delay or combine "Text Type" commands.


    For the record, this:

    If Not Program "XYZ.EXE" is focused
      Window Activate: XYZ
    End If

    is a published trick to speed up your macro. The "Window Activate" command takes a relatively long time to perform. By checking you can you can avoid the Window Activate command if the window is already focused.

  2. When Macro Express Pro loads up it checks to see if another instance of Macro Express Pro is already running. If it is then the new instance terminates. You cannot run two instances of Macro Express Pro in the same session.

    Paul, is it possible for a process running in one session to see the process from another session? I thought they were independent of each other.


    Edit, I see from Cory's response that .NET can see processes from other sessions.

  3. The Terminal Services Session ID command will tell you if you are using the Console or some other session. Could you use that information? Perhaps write it to a file. When a macro starts have it compare the current Session ID with the Session ID in the file. If they match you know that Macro Express forgot to clear the flag the last time it ran. If they do not match you know another session set the flag.


    Or, you may just decide to run the macros from the console session. I think the console session is always 1.


    What conflicts? Do you need a unique filename? If you include the Session ID as part of the filename you could ensure that you have a unique file for each session.

  4. Put Text Box Display commands before and after you Multiple Choice commands to display the value in your Choice variable. Put one outside the repeat loop to see when it gets out. This will help you figure out what is going wrong. If you expect to see "choice 1" and you are seeing "A" then you need to change to the Multiple Choice Menu's "Result Options" from "Save Item Value" to "Save Item Text".


    To have the macro perform different stuff when the user clicks Cancel, experiment with the options in the "On Error" tab of the Multiple Choice command. In my testing I found the "Variable Set String %Choice% to "" command before the Multiple Choice Menu necessary. YMMV

  5. What does your code look like? This sample macro works until the user leaves the choice blank or clicks the Cancel button.

    Repeat Until %Choice% Equals ""
      Variable Set String %Choice% to ""
      Multiple Choice Menu: Make Your Choice
      Text Box Display: Choice
      If Variable %Choice% Equals ""
      End If
    End Repeat
    The "On Error" "The dialog was cancelled" setting for the Multiple Choice Menu is at the default value of Halt Macro.
  6. If macro A does a Save Variables and sometime later macro B does a Restore Variables the variables in Macro B will contain values from Macro A. Sometimes this is intentional and needed but from what I have seen, it is more often unnecessary.


    When a macro is activated it receives its own copy of variables. In other words, all its variables are empty. If variables are defined as 'Global' they are passed to other macros called from the top level macro via a Macro Run command. The Save Variables and Restore Variables commands are not needed for this to happen. When a variable is not defined as Global the value of that variable is not passed to a macro called by the Macro Run command.


    The Save/Restore Variables command pair is one way to pass variables from one macro to another but it is not necessarily the best way. The Restore Variables command can be used to retrieve variables passed to a macro via the command line.

  7. Simple fix? Switch to WIndows 7 or 8. ;)


    Are you using NTFS or FAT32 on your Windows XP system? It may be that you just need to upgrade to NTFS.


    Here's what happens: Macro Express requests the files in a certain folder. On Windows XP (or FAT32) information for the files is returned in the order they were written to the disk drive. On Windows Vista and later (or, possibly on an NTFS system) when Macro Express requests the files from Windows they are returned in alphabetical order.


    When you use Windows Explorer it sorts the list of files based on your sort criteria. They may be alphabetical, by file type or modified date.


    As a workaround you could store the list of files in an array and then have a macro sort the array.

  8. not sure what you mean by using named variables (I don't see anything in the help file or manual)?


    This would be clearer:

      Get Pixel Color at (30, 88) Relative to Current Window into %PageIconColor%
      Get Pixel Color at (48, 107) Relative to Current Window into %LinksIconColor%
      Get Pixel Color at (48, 394) Relative to Current Window into %MacrosIconColor%

    Note the descriptive variable names instead of N2, N4 and N5.


    From the help (emphasis mine):

    Types of Variables

    Macro Express supports several different types of variables. These are Text, Integer, Large Integer, Decimal, Control, Date/Time, Boolean and Handle variables. Variable names may be up to 31 characters in length.

  9. It is easier if you post the text version of your script so we don't have to copy and paste it into a macro to help. To copy the commands to the clipboard highlight your macro commands, right-click and choose "Copy Command Text". Your macro looks like this:

    Variable Set Integer %N1% to 0
    Repeat Until %N1% Equals "1"
      Delay: 2 seconds
      // 'Page' icon
      Get Pixel Color at (30, 88) Relative to Current Window into %N2%
      // 'Links' icon
      Get Pixel Color at (48, 107) Relative to Current Window into %N4%
      // 'Macros' icon
      Get Pixel Color at (48, 394) Relative to Current Window into %N5%
      If Variable %N2% Equals "14061138"
      If Variable %N4% Equals "16241482"
      If Variable %N5% Equals "16250871"
        Variable Set Integer %N1% to 1
      End If
      Delay: 500 milliseconds
    End Repeat
    Mouse Move: 60, 87 Relative to Screen
    Mouse Left Click

    So, if ...


    The value of all 3 variables (N2, N4 and N5) are correct and N1 is set to 1!

    Then the macro is working correctly. It says when it is discovered that N2, N4 and N5 are set to specific values then set N1 to 1. When N1 is set to 1 the repeat loop stops.


    It appears to me that %N2% = "14061138", %N4% = "16241482" and %N5% Equals "16250871" so it sets N1 to 1 and the repeat loop should stop.

  10. This says

    "What it does:

    This sample macro shows how to change a date from MM-DD-YY to DD-MMM-YYYY format using the 'Run Macro in Variable' command."


    Thats not what i'm asking for.

    I suggested that sample macro because I thought the technique described, setting a date format using the "Run Macro in Variable" command, could be adapted to what you need.

  11. Cory already showed how to pass a variable from Macro Express Pro to a VBScript. Maybe this more detailed explanation will help you understand how it works.


    VBScript does not know anything about Macro Express Pro. It has no way to directly read the content of a Macro Express variable. Macro Express has its way to store variables. VBS has another way to store variables.


    To pass the content of a Macro Express Pro variable into a VBScript you have to use the VBS command to set a value to a variable. The format to create variables and set them to specific values in VBS looks something like this:

    strTest="gagangoomer's macro"

    To create variables in Macro Express Pro and set them to specific values do this:

    Variable Set Integer %intTemp% to 42
    Variable Set String %strTemp% to "gagangoomer's macro"

    Then, in the External Script command, include these lines:


    When the macro runs the External Script command and passes the script information to VBScript the contents of the Macro Express variables ("42" and "gagangoomer's macro" respectively) will be substituted for the variable names ("%intTemp%" and "%strTemp%") so WScript (the program that runs the VBScript) will see it like this:

    strTest="gagangoomer's macro"

    This is the way to pass a variable into VBScript via the External Script command.


    Another thing to consider would be to put the values you need into a resource that both Macro Express Pro and WScript / VBScript can access. If your VBScript can read from the registry you could have Macro Express Pro write values into the registry. Similiarly, Macro Express could write information into a file in a location where VBScript can read it. Paul suggested using the clipboard but you said that wouldn't work. I am not a VBScript expert but it would surprise me if a VBScript cannot read from the clipboard.

  12. The color 16777215 / 0xFFFFFF / 255 255 255 is white while 0 / 0x000000 / 000 000 000 is black. Each number can vary between 0 and 255 and represents how much Red, Green and Blue to display. If the computer displays all red, green and blue possible you get white and if it displays no red, green and blue you get black.


    Since colors are represented by numeric values it is possible create a "Wait for Pixel Color" function by creating a Repeat statement to wait until the value matches a certain color. In my macros I use OR statements to check for several colors. You need to be careful, though, because changing the Windows theme may require that you adjust your macro for the different colors.

  13. The portable version is written specifically for drives that can be removed from time to time. The standard version is meant to be installed on a drive that doesn't get removed.


    Your comment about licensing is a little confusing. If you have a 1-user license for the portable version then you should only be using it on one computer at a time. You can move it from computer to computer because it is portable. But if you install it on your HDD then I'm not sure the license allows you to use it on a flash drive for your other computer.


    The macros will run on either version of Windows. However, the parts of your macros that rely on things that change between Windows 7 and 8 may need to be written in a way that accomodates both. Just as one example, a macro written on Windows XP using the Calculater needed adjustments because the calculator program on Windows 7 was different. (I don't know if the Windows 8 calculator is different than the one on Windows 7 though.)

  • Create New...