Jump to content
Macro Express Forums

Samrae

Members
  • Posts

    452
  • Joined

  • Last visited

  • Days Won

    22

Posts posted by Samrae

  1. Sebastian,

     

    As was mentioned above you could use Macro Express commands to copy all files and folders in the Data folder to another folder. This example copies the files and folders from the folder Data to a folder that contains the date, e.g. E:\Data --> E:\Data09092021 while leaving the original Data folder intact.

     

    Variable Set String %SourceDir% to "E:\Data"
    Variable Set From File date
    Variable Set String %DestinationDir% to "E:\Data%FolderDay%%FolderMonth%%FolderYear%"
    Copy File/Files: "%SourceDir%\*.*" to "%DestinationDir%"

     

    <VARIABLE SET STRING Option="\x00" Destination="%SourceDir%" Value="E:\\Data" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET FROM FILE Filename="%SourceDir%" Option="\x00" Date="\x01" Month="%FolderMonth%" Day="%FolderDay%" Year="%FolderYear%" Flags="\x07"/>
    <VARIABLE SET STRING Option="\x00" Destination="%DestinationDir%" Value="E:\\Data%FolderDay%%FolderMonth%%FolderYear%" NoEmbeddedVars="FALSE"/>
    <COPY FILE/FILES Source="%SourceDir%\\*.*" Dest="%DestinationDir%" Progress="TRUE" Recurse="TRUE"/>

     

    If you want to rename the Data folder you can use the following. This example moves the files and folders from the folder Data to a folder that contains the date, e.g. E:\Data --> E:\Data09092021 . The original folder E:\Data is removed.

     

    Variable Set String %SourceDir% to "E:\Data"
    Variable Set From File date
    Variable Set String %DestinationDir% to "E:\Data%FolderDay%%FolderMonth%%FolderYear%"
    Rename File/Files: "%SourceDir%" to "%DestinationDir%"

     

    <VARIABLE SET STRING Option="\x00" Destination="%SourceDir%" Value="E:\\Data" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET FROM FILE Filename="%SourceDir%" Option="\x00" Date="\x01" Month="%FolderMonth%" Day="%FolderDay%" Year="%FolderYear%" Flags="\x07"/>
    <VARIABLE SET STRING Option="\x00" Destination="%DestinationDir%" Value="E:\\Data%FolderDay%%FolderMonth%%FolderYear%" NoEmbeddedVars="FALSE"/>
    <RENAME FILE/FILES Source="%SourceDir%" Dest="%DestinationDir%" Progress="FALSE" Recurse="FALSE"/>

     

    NOTE: the folder names cannot have a trailing "\" or contain "\*.*"  When they do the copy or rename does not work correctly.

     

    I used the folder's modified date to create a destination folder like E:\Data09092021. I did not include hours and minutes in the destination folder name. You can easily add these. You could also choose to use the date/time when the macro runs, similar to what you have above.

  2. There is a Scheduled Macro option to run "When the program starts". This may do what you need.

     

    If not you can use Windows Task Scheduler along with the Macro Express command line options to run a macro. The command line would look something like either of these:

    "c:\Program Files (x86)\Macro Express Pro 6\MeProc.exe" /A::Filename?Macroname
    
    "c:\Program Files (x86)\Macro Express Pro 6\MeProc.exe" /A:Macroname

     

  3. I could not get a batch file containing any of these to work:

    start C:\Program Files (x86)\Macro Express Pro\MeProc.exe /APosteingang
    
    start "C:\Program Files (x86)\Macro Express Pro\MeProc.exe /APosteingang"
    
    start "C:\Program Files (x86)\Macro Express Pro\MeProc.exe" /APosteingang

     

    But a batch file containing this worked on both Windows 7 and Windows 10:

    "C:\Program Files (x86)\Macro Express Pro\MeProc.exe" /APosteingang

     

    I expect the parameter in Dragon should look like this but I do not have Dragon to try it:

    ShellExecute "C:\Program Files (x86)\Macro Express Pro\MeProc.exe" /APosteingang

     

    Have you considered upgrading to Macro Express Pro 6? Maybe it contains a change that would help.

  4. You can still use Text File Process to loop through the text.

     

    Each line of a text file used by Windows ends with CR followed by LF referred to as CRLF. The Text File Begin/End process reads a line of text up to the CRLF. For convenience in your macro the string read by Text File Process does not include the CRLF.  However, in your case, you know that each line originally had the CRLF. So, to determine the number of CRLF's just count the lines. Something like this:

     

    Variable Set Integer %N99% to 0
    Text File Begin Process: "ansisavedcopy.txt"
      Variable Modify Integer: Inc (%N99%)
      
      // If the line is empty then stop the Text File loop
      If Variable %T1% = ""
        Break
      End If
    Text File End Process
    
    // Here: %N99% contains the number of times through the loop. This is also the number of CRLF's found.

     

    This sample does what you described. I counts the number of CRLF's found and it stops when the line is blank.

     

    There are some file formats that use only CR or only LF. If that were the case then you would have to read the entire file into a variable and parse through it. But, since Notepad+ indicates the file is ANSI format we know that each line of your file ends with CRLF.

     

    • Thanks 1
  5. The Text File Begin Process will read one line at a time and put it into your variable %T1% ... without a CRLF. Variable %T1% will not contain a CRLF.

     

    In your example the first time through the Text File Begin Process loop %T1% will contain "My Requisition Statuses"  (no CRLF).

    The second time through the loop %T1% will contain "Create Requisition" (again, no CRLF).

    The third time through the loop %T1% will contain "Procurement Templates" (still no CRLF).

     

    To see how these things work load the file asniSavedCopy.txt into variable %T2%. Then do the "Variable Set Integer %N1% from Position of Text in variable %T2%. The variable %N1% will be set to 24 (Assuming the first line contains "My Requisition Statuses<CR><LF>"

     

    What are you trying to accomplish? We might be able to help you better if we understand your goal.

  6. This worked for me:

    DOSCommandSample.PNG.7591c49adc3ea9eacdd91264cfb74f20.PNG

     

    The /c parameter tells cmd.exe to close after running. %TEMP% points to the temporary folder.

     

    You could also put commands in a batch file

    c:
    cd %TEMP%
    dir > %TEMP%\DirCmd.txt

     

    and use the Program Launch command to run the batch file.

    DOSCommandSample2.PNG.28ce4e88a89ce704024b9895301393dd.PNG

     

    And then, as rberg said, load the file into a macro via a 'Variable Set String %T1% from File' command or the Text File Begin process command.

     

     

    • Like 1
  7. 5 hours ago, terrypin said:

    BTW, isn't it curious that our versions of MX Pro use different command text 🙂

     

    
      Text Type (Simulate Keystrokes): <UP ARROW><UP ARROW><UP ARROW><ARROW UP><ARROW UP>

     

    Huh.  I had never noticed that before. I got curious so I did some testing.

     

    Captured macros have:

    Text Type (Simulate Keystrokes): <DOWN ARROW><LEFT ARROW><RIGHT ARROW><UP ARROW>

     

    The Text Type command enters:

    Text Type (Simulate Keystrokes): <ARROW DOWN><ARROW LEFT><ARROW RIGHT><ARROW UP>

     

    Both forms work. Interesting.

  8. The Lock Player and Unlock Player commands are added when you load a macro created in Macro Express 3 into Macro Express Pro 4. There is a checkbox that asks if you want to add them. Lock Player is used to prevent another macro launching while the first macro is still running. This has been useful to me on rare occasions.

     

    When you select an item in a popup menu a few things occur:

     1. The popup menu disappears

     2. The active window changes

     3. The typing (or whatever the macro does) begins.

     

    It sounds like step 3 is starting before Windows finishes with steps 1 and 2. The amount of time to accomplish steps 1 and 2 can vary depending on the speed of your computer and what is running. The same macros on a different computer may behave differently.

     

  9. 1 hour ago, Cory said:

    I was wrong. MEP works fine in UWP apps. I've been doing my activations incorrectly. I apologize for the misinformation. 

    No, you were not wrong. UWP programs do not follow long established standards for Windows programming. Hooks work but many hotkeys are blocked. I cannot launch a UWP .exe using the Program Launch command so I have to launch it from the menus. They do not use Alt key shortcuts. The is no File menu. They are very slow and require long delays. They do not support Window Controls.

     

    Because you prefer to use Window Controls your statement that macros do not not work with UWP programs is not incorrect.

     

    Specifically, in this case, your macro activated with Ctrl+Keypad 9 did not activate. Changing the hotkey to Ctrl+Shift+b worked.

     

    Working with UWP programs is tedious and frustrating. But, with effort, I have been able to get macros to work with them. Your mileage may vary.

  10. Do you have a macro that uses the Keystroke Speed command? I discovered that if one macro sets the Keystroke Speed, to 500 say, and does not reset it back to 0 then all other macros that I run after that type text slowly. I try to remember to set Keystroke Speed back to 0 in any macro that changes it.

     

    You could check for this by putting a Keystroke Speed: 0 at the top of one of your macros that is typing slowly. If it starts to work more quickly you can search for the macro that slows down the keystroke speed.

     

    Another thing to check is whether the Delay after keystroke value found in Playback, Delays has been changed. The default value for this is 300.

  11. It has been stated several times on forum that Macro Express does not work with UWP programs. That is not my experience. UWP programs behave differently than Win32 programs but, with some effort, I have been able to get Macro Express to work with them.

     

    I took this as a challenge to get Macro Express to work with Windows 10 Settings. Here is a macro that opens Windows Settings, navigates to Apps & Features, and closes Settings.

     

    Note: This macro was written with Macro Express Pro 6, not ME 4.

    // -----------------------------------
    //   Initialization
    // -----------------------------------
    Variable Set Decimal %SDelay% to 0.1 // Short delay
    Variable Set Decimal %MDelay% to 1 // Medium delay
    
    Variable Set Decimal %LDelay% to 2 // Long delay
    Keystroke Speed: 200 milliseconds
    Text Box Display: Progress ...
     
    // -----------------------------------
    //   Open Windows Settings
    // -----------------------------------
    If Not Window "Settings" is running
      Text Type (Simulate Keystrokes): <WIND>
      Delay: %SDelay% seconds
      Text Type (Simulate Keystrokes): <WINU>
      Delay: %MDelay% seconds
      Text Type (Simulate Keystrokes): Settings
      Delay: %SDelay% seconds
      Text Type (Simulate Keystrokes): <ENTER>
      Text Box Update: Progress ...
      Wait for Window Title: Settings
    End If
     
     
    Delay: %LDelay% seconds
     
    // Set focus to Windows Settings
    If Window "Settings" is running
      Text Box Update: Progress ...
      If Not Window "Settings" is focused
        Text Box Update: Progress ...
        Window Activate: Settings
        Delay: %LDelay% seconds
      End If
       
      If Program "SYSTEMSETTINGS.EXE" is running
       
        Text Box Update: Progress ...
         
        // Type
        Delay: %MDelay% seconds
        Text Type (Simulate Keystrokes): Apps &
        Delay: %MDelay% seconds
        Text Type (Simulate Keystrokes): <ENTER>
        Delay: %MDelay% seconds
        Text Type (Simulate Keystrokes): <ENTER>
         
        Text Box Update: Progress ...
        If Message "Close Settings?"
          Delay: %sDelay% seconds
           
          // Restore focus to Settings
          If Not Window "Settings" is focused
            Text Box Update: Progress ...
            Window Activate: Settings
            Delay: %LDelay% seconds
          End If
           
          // Now close Settings
          Text Box Update: Progress ...
          Text Type (Simulate Keystrokes): <ALTD><SPACE><ALTU>
          Delay: %sDelay% seconds
          Text Type (Simulate Keystrokes): c
           
           
          Text Box Update: Progress ...
          Delay: 1.5 seconds
        End If
         
         
      End If
    End If
     
    // -----------------------------------
    //   Done
    // -----------------------------------
    Keystroke Speed: 0 milliseconds
    <COMMENT Value="-----------------------------------"/>
    <COMMENT Value="  Initialization"/>
    <COMMENT Value="-----------------------------------"/>
    <VARIABLE SET DECIMAL Option="\x00" Destination="%SDelay%" Value="0.1" _COMMENT="Short delay"/>
    <VARIABLE SET DECIMAL Option="\x00" Destination="%MDelay%" Value="1" _COMMENT="Medium delay\r\n"/>
    <VARIABLE SET DECIMAL Option="\x00" Destination="%LDelay%" Value="2" _COMMENT="Long delay"/>
    <KEYSTROKE SPEED Delay="200"/>
    <TEXT BOX DISPLAY Title="Progress ..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Launcing SystemSettings\\f1 \r\n\\par }\r\n" Left="Center" Top="20" Width="564" Height="143" Monitor="0" OnTop="TRUE" Keep_Focus="FALSE" Mode="\x02" Delay="0"/>
    <COMMENT/>
    <COMMENT Value="-----------------------------------"/>
    <COMMENT Value="  Open Windows Settings"/>
    <COMMENT Value="-----------------------------------"/>
    <IF NOT WINDOW Option="\x01" Title="Settings" Partial="TRUE" Wildcards="FALSE"/>
    <TEXT TYPE Action="0" Text="<WIND>"/>
    <DELAY Flags="\x01" Time="%SDelay%"/>
    <TEXT TYPE Action="0" Text="<WINU>"/>
    <DELAY Flags="\x01" Time="%MDelay%"/>
    <TEXT TYPE Action="0" Text="Settings"/>
    <DELAY Flags="\x01" Time="%SDelay%"/>
    <TEXT TYPE Action="0" Text="<ENTER>"/>
    <TEXT BOX UPDATE Header="Progress ..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red0\\green0\\blue128;}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Wait for Window \\cf1\\b Settings\\cf0\\b0\\f1 \r\n\\par }\r\n"/>
    <WAIT FOR WINDOW TITLE Title="Settings" Partial="TRUE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="45"/>
    <END IF/>
    <COMMENT/>
    <COMMENT/>
    <DELAY Flags="\x01" Time="%LDelay%"/>
    <COMMENT/>
    <COMMENT Value="Set focus to Windows Settings"/>
    <IF WINDOW Option="\x01" Title="Settings" Partial="TRUE" Wildcards="FALSE"/>
    <TEXT BOX UPDATE Header="Progress ..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red0\\green0\\blue128;}\r\n\\viewkind4\\uc1\\pard\\cf1\\b\\f0\\fs20 Settings\\b0  is running\\cf0\\f1 \r\n\\par }\r\n"/>
    <IF NOT WINDOW Option="\x00" Title="Settings" Partial="TRUE" Wildcards="FALSE"/>
    <TEXT BOX UPDATE Header="Progress ..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red0\\green0\\blue128;}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Set Focus to \\cf1\\b Settings\\cf0\\b0\\f1 \r\n\\par }\r\n"/>
    <WINDOW ACTIVATE Title="Settings" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
    <DELAY Flags="\x01" Time="%LDelay%"/>
    <END IF/>
    <COMMENT/>
    <IF PROGRAM Option="\x01" Program="SYSTEMSETTINGS.EXE"/>
    <COMMENT/>
    <TEXT BOX UPDATE Header="Progress ..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red0\\green0\\blue128;}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Select Apps in \\cf1\\b Settings\\cf0\\b0\\f1 \r\n\\par }\r\n"/>
    <COMMENT/>
    <COMMENT Value="Type"/>
    <DELAY Flags="\x01" Time="%MDelay%"/>
    <TEXT TYPE Action="0" Text="Apps &"/>
    <DELAY Flags="\x01" Time="%MDelay%"/>
    <TEXT TYPE Action="0" Text="<ENTER>"/>
    <DELAY Flags="\x01" Time="%MDelay%"/>
    <TEXT TYPE Action="0" Text="<ENTER>"/>
    <COMMENT/>
    <TEXT BOX UPDATE Header="Progress ..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red0\\green0\\blue128;}\r\n\\viewkind4\\uc1\\pard\\cf1\\b\\f0\\fs20 Settings\\b0  is loaded\\cf0\\f1 \r\n\\par }\r\n"/>
    <IF MESSAGE Caption="Close Settings?" Message="Do you want to close Settings now?" BtnMode="\x00" Default="TRUE" Left="Center" Top="40" Monitor="0" Delay="0"/>
    <DELAY Flags="\x01" Time="%sDelay%"/>
    <COMMENT/>
    <COMMENT Value="Restore focus to Settings"/>
    <IF NOT WINDOW Option="\x00" Title="Settings" Partial="TRUE" Wildcards="FALSE"/>
    <TEXT BOX UPDATE Header="Progress ..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red0\\green0\\blue128;}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Set Focus to \\cf1\\b Settings\\cf0\\b0\\f1 \r\n\\par }\r\n"/>
    <WINDOW ACTIVATE Title="Settings" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
    <DELAY Flags="\x01" Time="%LDelay%"/>
    <END IF/>
    <COMMENT/>
    <COMMENT Value="Now close Settings"/>
    <TEXT BOX UPDATE Header="Progress ..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red0\\green0\\blue128;}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Closing \\cf1\\b Settings\\cf0\\b0\\f1 \r\n\\par }\r\n"/>
    <TEXT TYPE Action="0" Text="<ALTD><SPACE><ALTU>"/>
    <DELAY Flags="\x01" Time="%sDelay%"/>
    <TEXT TYPE Action="0" Text="c"/>
    <COMMENT/>
    <COMMENT/>
    <TEXT BOX UPDATE Header="Progress ..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red0\\green0\\blue128;}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Closed \\cf1\\b Settings\\cf0\\b0\\f1 \r\n\\par }\r\n"/>
    <DELAY Flags="\x01" Time="1.5"/>
    <END IF/>
    <COMMENT/>
    <COMMENT/>
    <END IF/>
    <END IF/>
    <COMMENT/>
    <COMMENT Value="-----------------------------------"/>
    <COMMENT Value="  Done"/>
    <COMMENT Value="-----------------------------------"/>
    <KEYSTROKE SPEED Delay="0"/>

     

×
×
  • Create New...