Jump to content
Macro Express Forums

rberq

Members
  • Posts

    989
  • Joined

  • Last visited

  • Days Won

    44

Posts posted by rberq

  1. 12 hours ago, Sebastian42 said:

    Since I thought I had come to the end of the road in Macro Express, and was going to run the macro from a batchfile anyway, I've explored doing the data copy by batch file code, and with help from someone in the Microsoft Community, I've been able to achieve that with one very simple line of code, which HAS to be preferable to the more complex code suggested in the previous post.

    Sometimes ME can dynamically build (then run) the simple line of code, or the whole batch file.  That's not needed if the batch commands do exactly the same thing every time, but it is useful if the batch does the same "function" but with variable data.  For example, macro 1 runs a standard directory list with output to a text file; macro 2 reads back the text, analyzes data file sizes, builds a different "copy" command batch file for each data file based on how big the file is today and whether the backup should be compressed or not; macro 3 runs the copies a few at a time to avoid overloading the server.  (That's a real application, as you may have guessed.)

     

    In other words, macros can utilize the simple and efficient batch commands, while applying logic and intelligence that otherwise would be lacking. 

  2. 6 hours ago, Sebastian42 said:

    It's not obvious to me where you got that list of running processes

    I have a macro that does it, using the Repeat with Processes command:

     

    <COMMENT Value=" "/>
    <COMMENT Value=" "/>
    <LOCK PLAYER Wait="TRUE" _ENABLED="FALSE"/>
    <LOG MESSAGES Filename="C:\\Temp\\MacroExpressProLogFiles\\MacroExpressPro_Macro_Log_File.txt" Message="Macro executed: 0_Running_Processes_Display_on_Screen" Stamp="TRUE"/>
    <LOG ERRORS Filename="C:\\Temp\\MacroExpressProLogFiles\\MacroExpressPro_Macro_Log_File.txt" Hide_Errors="FALSE"/>
    <COMMENT Value=" "/>
    <COMMENT Value="Display all running processes"/>
    <COMMENT Value=" "/>
    <COMMENT Value="....    set up CR-LF in T98"/>
    <VARIABLE SET TO ASCII CHAR Value="13" Destination="%T[98]%"/>
    <VARIABLE SET TO ASCII CHAR Value="10" Destination="%T[99]%"/>
    <VARIABLE MODIFY STRING Option="\x07" Destination="%T[98]%" Variable="%T[99]%" NoEmbeddedVars="FALSE"/>
    <COMMENT Value=" "/>
    <VARIABLE SET STRING Option="\x00" Destination="%T[1]%" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%T[2]%" NoEmbeddedVars="FALSE"/>
    <REPEAT WITH PROCESSES Destination="%T[1]%"/>
    <VARIABLE MODIFY STRING Option="\x07" Destination="%T[2]%" Variable="%T[1]%" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x07" Destination="%T[2]%" Variable="%T[98]%" NoEmbeddedVars="FALSE"/>
    <END REPEAT/>
    <COMMENT Value=" "/>
    <COMMENT Value="Process names are stacked in T2 variable, with trailing CRLF. "/>
    <COMMENT Value="Now split variable T2 out into an array, to be sorted.  Append CRLF to each name.  "/>
    <SPLIT STRING Source="%T[2]%" SplitChar="%T[98]%" Dest="%ProcessNames%" Index="1"/>
    <COMMENT Value=" "/>
    <COMMENT Value="Testing, make sure last three array slots are full and all slots have some value"/>
    <VARIABLE SET STRING Option="\x00" Destination="%ProcessNames[250]%" Value="ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%ProcessNames[300]%" Value="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%ProcessNames[299]%" Value="YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%ProcessNames[298]%" Value="ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%sortindex1%" Value="1" _ENABLED="FALSE"/>
    <GET ARRAY LENGTH Array="%ProcessNames%" Dest="%arraylength%" _ENABLED="FALSE"/>
    <REPEAT UNTIL Variable="%sortindex1%" Condition="\x03" Value="%arraylength%" _ENABLED="FALSE"/>
    <IF VARIABLE Variable="%ProcessNames[%sortindex1%]%" Condition="\x00" IgnoreCase="FALSE" _ENABLED="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%ProcessNames[%sortindex1%]%" Value="ZZ" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/>
    <END IF _ENABLED="FALSE"/>
    <VARIABLE MODIFY INTEGER Option="\x07" Destination="%sortindex1%" _ENABLED="FALSE"/>
    <END REPEAT _ENABLED="FALSE"/>
    <COMMENT Value=" "/>
    <COMMENT Value="Sort array of process names "/>
    <GET ARRAY LENGTH Array="%ProcessNames%" Dest="%arraylength%"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%sortindex1%" Value="0"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%sortindex2%" Value="0"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%sortlimit%" Value="%arraylength%"/>
    <VARIABLE MODIFY INTEGER Option="\x08" Destination="%sortlimit%"/>
    <REPEAT UNTIL Variable="%sortindex1%" Condition="\x00" Value="%sortlimit%"/>
    <VARIABLE MODIFY INTEGER Option="\x07" Destination="%sortindex1%"/>
    <VARIABLE MODIFY INTEGER Option="\x00" Destination="%sortindex2%" Value1="%sortindex1%" Value2="1"/>
    <IF VARIABLE Variable="%ProcessNames[%sortindex1%]%" Condition="\x00" IgnoreCase="FALSE"/>
    <REPEAT EXIT/>
    <END IF/>
    <REPEAT UNTIL Variable="%sortindex2%" Condition="\x03" Value="%arraylength%"/>
    <TEXT BOX DISPLAY Title="Diagnostics -- indexes" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %sortindex1%\r\n\\par %sortindex2%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
    <IF VARIABLE Variable="%ProcessNames[%sortindex2%]%" Condition="\x00" IgnoreCase="FALSE"/>
    <REPEAT EXIT/>
    <END IF/>
    <IF VARIABLE Variable="%ProcessNames[%sortindex1%]%" Condition="\x03" Value="%ProcessNames[%sortindex2%]%" IgnoreCase="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x08" Destination="%tempname%" Variable="%ProcessNames[%sortindex1%]%" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x08" Destination="%ProcessNames[%sortindex1%]%" Variable="%ProcessNames[%sortindex2%]%" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x08" Destination="%ProcessNames[%sortindex2%]%" Variable="%tempname%" NoEmbeddedVars="FALSE"/>
    <END IF/>
    <VARIABLE MODIFY INTEGER Option="\x07" Destination="%sortindex2%"/>
    <END REPEAT/>
    <END REPEAT/>
    <COMMENT Value=" "/>
    <COMMENT Value="Testing skip counting and removing duplicates *********************************************" _ENABLED="FALSE"/>
    <IF VARIABLE Variable="%skip%" Condition="\x01" Value="%skip%" IgnoreCase="FALSE" _ENABLED="FALSE"/>
    <COMMENT Value="Remove and count duplicate names from list "/>
    <GET ARRAY LENGTH Array="%ProcessNames%" Dest="%arraylength%"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%sortindex1%" Value="0"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%sortindex2%" Value="0"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%sortlimit%" Value="%arraylength%"/>
    <VARIABLE MODIFY INTEGER Option="\x08" Destination="%sortlimit%"/>
    <REPEAT UNTIL Variable="%sortindex1%" Condition="\x00" Value="%sortlimit%"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%dupcount%" Value="1"/>
    <VARIABLE MODIFY INTEGER Option="\x07" Destination="%sortindex1%"/>
    <VARIABLE MODIFY INTEGER Option="\x00" Destination="%sortindex2%" Value1="%sortindex1%" Value2="1"/>
    <IF VARIABLE Variable="%ProcessNames[%sortindex1%]%" Condition="\x01" IgnoreCase="FALSE" _COMMENT="****1"/>
    <REPEAT UNTIL Variable="%sortindex2%" Condition="\x03" Value="%arraylength%"/>
    <TEXT BOX DISPLAY Title="Diagnostics -- indexes" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %sortindex1%\r\n\\par %sortindex2%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
    <IF VARIABLE Variable="%ProcessNames[%sortindex2%]%" Condition="\x00" IgnoreCase="FALSE" _COMMENT="                     ****2"/>
    <OR/>
    <IF VARIABLE Variable="%ProcessNames[%sortindex2%]%" Condition="\x03" Value="%ProcessNames[%sortindex1%]%" IgnoreCase="FALSE"/>
    <IF VARIABLE Variable="%dupcount%" Condition="\x03" Value="1" IgnoreCase="FALSE" _COMMENT="                                               ****3"/>
    <VARIABLE MODIFY STRING Option="\x06" Destination="%ProcessNames[%sortindex1%]%" Value=" (" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x06" Destination="%ProcessNames[%sortindex1%]%" Value="%dupcount%" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x06" Destination="%ProcessNames[%sortindex1%]%" Value=" instances)" NoEmbeddedVars="FALSE"/>
    <REPEAT EXIT/>
    <END IF _COMMENT="                                                                                                        ****3"/>
    <END IF _COMMENT="                                                                             ****2"/>
    <IF VARIABLE Variable="%ProcessNames[%sortindex1%]%" Condition="\x00" Value="%ProcessNames[%sortindex2%]%" IgnoreCase="FALSE" _COMMENT="      ****4"/>
    <VARIABLE MODIFY INTEGER Option="\x07" Destination="%dupcount%"/>
    <VARIABLE SET STRING Option="\x00" Destination="%ProcessNames[%sortindex2%]%" NoEmbeddedVars="FALSE"/>
    <END IF _COMMENT="                                                                                                                                                 ****4"/>
    <VARIABLE MODIFY INTEGER Option="\x07" Destination="%sortindex2%"/>
    <END REPEAT/>
    <END IF _COMMENT="                                                                                                 ****1"/>
    <END REPEAT/>
    <COMMENT Value=" "/>
    <COMMENT Value="Testing skip counting and removing duplicates *********************************************" _ENABLED="FALSE"/>
    <END IF _ENABLED="FALSE"/>
    <COMMENT Value=" "/>
    <COMMENT Value=" "/>
    <COMMENT Value=" "/>
    <COMMENT Value="Pull process names out of array, stack into %Display% with CRLF appended to each "/>
    <GET ARRAY LENGTH Array="%ProcessNames%" Dest="%arraylength%"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%index1%" Value="0"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%processcounter%" Value="0"/>
    <VARIABLE SET STRING Option="\x00" Destination="%display%" NoEmbeddedVars="FALSE"/>
    <REPEAT START Start="1" Step="1" Count="%arraylength%" Save="FALSE"/>
    <VARIABLE MODIFY INTEGER Option="\x07" Destination="%index1%"/>
    <IF VARIABLE Variable="%ProcessNames[%index1%]%" Condition="\x01" IgnoreCase="FALSE"/>
    <VARIABLE MODIFY INTEGER Option="\x07" Destination="%processcounter%"/>
    <VARIABLE MODIFY STRING Option="\x07" Destination="%display%" Variable="%ProcessNames[%index1%]%" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x07" Destination="%display%" Variable="%T[98]%" NoEmbeddedVars="FALSE"/>
    <END IF/>
    <END REPEAT/>
    <COMMENT Value=" "/>
    <TEXT BOX DISPLAY Title="List of running processes" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\lang1033\\f0\\fs20 Number of processes: %processcounter%\r\n\\par \\f1 %\\f0 display\\f1 %\r\n\\par }\r\n" Left="Center" Top="Center" Width="632" Height="703" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
    <COMMENT Value=" "/>
    <COMMENT Value="Restore variables used by this macro" _ENABLED="FALSE"/>
    <VARIABLE SET STRING Option="\x0B" Destination="%T[1]%" Value="WIN_DISPLAY_SAVE_T1" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/>
    <VARIABLE SET STRING Option="\x0B" Destination="%T[2]%" Value="WIN_DISPLAY_SAVE_T2" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/>
    <VARIABLE SET STRING Option="\x0B" Destination="%T[98]%" Value="WIN_DISPLAY_SAVE_T98" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/>
    <VARIABLE SET STRING Option="\x0B" Destination="%T[99]%" Value="WIN_DISPLAY_SAVE_T99" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/>
    <COMMENT Value=" "/>
    <COMMENT Value="Done - exit"/>
    <MACRO RETURN/>
    <UNLOCK PLAYER _ENABLED="FALSE"/>
    `````

  3. Now and then a version of Firefox comes along that doesn't want to close.  I use a .bat file as shown below, to kill and restart Firefox.  There are multiple "taskkill" commands, because there tends to be more than one Firefox process running -- don't know why.  The .bat file can be launched from a macro:
       Program Launch: "c:\menus\kill_firefox.bat" (Normal) Parameters:


    taskkill /F /IM firefox.exe
    taskkill /F /IM firefox.exe
    taskkill /F /IM firefox.exe
    taskkill /F /IM firefox.exe
    taskkill /F /IM firefox.exe
    taskkill /F /IM firefox.exe
    taskkill /F /IM firefox.exe
    taskkill /F /IM firefox.exe
    taskkill /F /IM firefox.exe
    taskkill /F /IM firefox.exe

    "C:\Program Files\Mozilla Firefox\firefox.exe"

  4. In my version of Firefox (91.0.2) the following sequence opens the library, then the Import & Backup, then the Backup screen.  I'm not sure why you need a "GET CONTROL".

     

    Text Type (Simulate Keystrokes): <CTRLD><SHIFTD>o<SHIFTU><CTRLU>    (library)
    Delay: 250 milliseconds
    Text Type (Simulate Keystrokes): <ALTD>I<ALTU>    (import/backup)
    Delay: 250 milliseconds
    Text Type (Simulate Keystrokes): B   (backup screen)

     

     

  5. Yes, it certainly can be done.  Presumably you would use one macro to save the initial size and re-size the window; and a second macro to restore the initial size. 

     

    Command VARIABLE SET INTEGER can be used to load the original location and dimensions of the window into variables.  Commands WINDOW RESIZE and/or WINDOW REPOSITION and/or WINDOW MOVE AND SIZE can change the location and dimensions.  All pretty straightforward. 

     

    The hardest part probably is storing the integer values somewhere so they can be retrieved when it is time to reset the window location and size to the original.  Because it's simple and straightforward, I prefer writing the values to a temporary .txt file, and then reading the file when it's time to reset the window.  There are other places to store the values, such as environment variables or the registry.

  6. 2 hours ago, robgratt said:

    Tabbing to a specific button won't work either as the layout is different for each site.

    Perhaps you need a separate macro for each site.

    I'm not sure what you mean by "testing" the sites. 

    You can connect to a web site from within a macro like this (though I'm not quite sure why it works):

    Program Launch: "//www.maine.gov/dhhs/mecdc/infectious-disease/epi/airborne/coronavirus/data.shtml"" (Maximized)
    Parameters:

     

  7. First thing I would try is:

     

    1) Right-click and rename the file appending whatever extension is desired:  filename.ext becomes filename.ext.xyz

    2) Double-click the name or ENTER to open it with the xyz-associated application; or launch the application via the macro

    3) Use a second macro to rename it back to the original after editing or whatever you want to do with the file

     

    Might run into trouble with this, there may well be some hitch I'm not thinking of.

    If all you want to do is look at the file, and don't plan to change and save it, the macro could copy it to a Temp folder/name with the xyz extension, and open it there. 

  8. 3 hours ago, acantor said:

    The problem I've had with UNTIL loops is the ease of getting into infinite loops.

     

    Ah, but don't we all write intentionally-infinite loops (REPEAT UNTIL %X% IS NOT EQUAL TO %X%)?  We do that because REPEAT START does not have a REPEAT INDEFINITELY option.  But I agree -- it is always wise to explicitly limit the loop in case, heaven forbid, we commit an error in logic.  Also, I generally embed the same 1/10 second delays like Cory does, if it's a macro the user is waiting for.  Longer or shorter delays when waiting for the computer itself to finish doing something, when human perception is not involved. 

  9. Look at the Repeat instructions.  There is a "Repeat Until ...." that should do what you want. 

    Though the logic might be easier if you use "Repeat Start...".  For example,

     

    REPEAT START

    IF COLOR1 = XXXX

       AND 

    IF COLOR2 = YYYYY

       DO STUFF

    ELSE

    REPEAT EXIT

    END IF

    END REPEAT

  10. 10 hours ago, Sebastian42 said:

    To open one, File > Open File....  That is too cumbersome for my purposes - I want to activate them by hotkey.

    A .mex file is not a macro.  A .mex file contains many individual macros.  You don't have to open the .mex file every time you want to activate a macro.  Once you open it, it stays open, and all the macros within it can be activated via their hotkeys. 

  11. If you copy the .mex file AFTER installing MEP on the new computer, the installation will already have created a .mex file.  In Macro Explorer you can select File | Open to access the copy containing your macros, rather than the skeleton produced by installation. 

  12. See screen image below.  The file that MEP is working from should appear at the bottom of the screen, where the red arrow is pointing. 

     

    You can copy the entire .mex file from the 'old' computer, and put it on the new computer -- just be sure to name it differently from the file that MEP is working from.  Then in Macro Explorer, select File | Import | Import Macros, specify the copied .mex file at the bottom of the import screen, click Open, then select the individual macros to be imported. 

     

    ScreenCapture_7_8_2021_15_06_04.jpg

  13. Do you mean Macro Express no longer starts up automatically when you start Windows?  Or do you mean it no longer works, period, even if you start ME manually? 

     

    Try reinstalling Macro Express and see if that starts it working again as you expect it to work.  Then just for fun see if the deleted items have come back. 

  14. I'm going to make a SWAG (Silly Wild-A** Guess).  It's not a solution so it will satisfy no one.  And my knowledge of Windows structure is vague enough I could be totally wrong.  There -- so much for disclaimers. 

     

    Q-Dir has been around for a long time.  Over the years, an application's relationship to the keyboard has evolved from the primitive ability to interact directly with the BIOS, to present-day highly-structured "layers" of software between the application and the hardware.  Perhaps Q-Dir generally adheres to Windows conventions, but has an old embedded module or two using an outdated technique that still works, but that sneaks in below the officially-correct level used by MEX.  Like coming in the back door instead of the front.  So sometimes MEX and Q-Dir communicate just fine, and sometimes not. 

     

    OK, there's my semi-magical-mystical view of the machine's mind.  Works for me, you guys can come up with your own religion.  😐

    • Haha 1
  15. I have had macro typing fail intermittently if the keystrokes are entered too fast. 

    Most of my macros have this standard command at the beginning:

    Keystroke Speed: 30 milliseconds 

    That's usually fast enough to keep me from fidgeting, but slow enough so the application is not overwhelmed. 

     

    Edit: Oops!  We posted at the same time.  I see you have already tried that.

  16. 2 hours ago, acantor said:

    Add an instruction to your macro to pop a message box as a way to confirm your macros are getting activated.

     

    
    MessageBox: The hotkey was recognized!

    You can insert message boxes like this at many critical points in your macro, to determine how far the macro has progressed.  Within the message box you can also display the values of variables, if you are wondering why IF conditions are not being met, and so on.  Once debugging is complete, remove the message box commands -- or, better, just inactivate the commands so you can re-activate them six months from now when something changes and the macro suddenly stops working. 😉

  17. IF the Citation window ALWAYS appears in the same location on the screen, perhaps your macro could move the mouse to the specific location on the screen where the icon resides, then click the mouse.  I have several macros triggered by hotkeys that do this, and as long as I run full-screen windows, the icon location is consistent.  Of course, an application update sometimes moves the icons a little bit, then the macro must be adjusted for the new location. 

  18. 2 hours ago, acantor said:

    Although I don't know a straightforward way to create Macro Express variables on-the-fly, that doesn't mean it's impossible. Many years ago, I developed a Macro Express script that generated other Macro Express scripts. I wonder whether the approach could be applied to the problem of generating variables.

    I was thinking of something similar.  Maybe open the script in the Direct Editor, copy all to the clipboard, manipulate whatever needs to be manipulated to add a variable, then paste the modified content back into the Direct Editor, overlaying the original macro.  Seems like a good way to get into trouble .... 

     

    I have been trying to figure out why anyone would WANT to create variables on the fly.  Perhaps to set up the "data" environment all at once, before starting to write the procedural logic for a macro.  You could make a spreadsheet or text file with variable names and attributes, then read the file with a macro and make the variables all at once.  Labor saver???  Or not?

×
×
  • Create New...