Jump to content
Macro Express Forums

rberq

Members
  • Posts

    1,195
  • Joined

  • Last visited

  • Days Won

    61

Posts posted by rberq

  1. I'm running ME 4.9.1.1 with Windows 10.  ME allows me to assign F1 as a hotkey, and I have been using it that way for quite some time.  When I assign it to activate the macro, it tells me there is another global macro already using it, and recommends I make it program specific -- but I can't find any other macro using F1.  I have code within the macro that effectively makes it program specific, by exiting if I'm not in the expected window.  If I hit F1 when Macro Explorer is active, the macro runs and exits, AND Macro Express Help opens up. 

     

    Not sure any of that helps you, but there it is. 

  2. The only partial solution I have found is to trigger the macro with the mouse.  Instead of (or in addition to) a hot-key combination, a Mouse Event can activate a macro.  (Look at the Activation tab for the macro.)  You can specify some unused area of the screen which you click on to start your macro.  Not the most convenient, but maybe it would work for you. 

     

    A similar method would be having a macro that runs continuously, repeatedly checking mouse coordinates.  When you move the mouse to some pre-determined area of the screen, this monitoring macro would then start the prompting macro.  You would want a delay built into the Repeat loop of the monitor, so it wouldn't excessively hog processor time -- half-second delays should be adequate but still give quick response time. 

  3. Like acantor said. 

    Also, sometimes you can search for text within a button that can be either clicked or activated with the ENTER key.  For example, the snippet below logs me out of several web sites:

     

        Text Type (Simulate Keystrokes): <HOME>
        Text Type (Simulate Keystrokes): <CTRLD>f<CTRLU>log out<ESC>
        Delay: 250 milliseconds
        Text Type (Simulate Keystrokes): <ENTER>

     

    It would be handy if there were a browser operation to find text AND automatically position the mouse over that text.  

  4. When each record of the CSV file is accessed, I think that ALL elements of array T are cleared, then populated with values from the current record. 

    Your macro saves inventory in T[99], but that will be cleared to null when processing of the next record begins because it is part of the same array. 

    Therefore command "If Variable %T[1]% Does not Equal "%T[99]%"" will ALWAYS find T[1] unequal to T[99]. 

    Try defining a new text variable in which you save inventory, and change the "If Variable" command to use that as well.  Any single non-array variable should work -- call it TSAVE or something else meaningful. 

     

    I'm not sure of the above, but it's easy for you to test. 

  5. 11 hours ago, acantor said:

    Very nice, rberq! I'd be curious to learn how your macro detects the second key press.

     

    I could not get "wait for keystroke" to work consistently, so I gave up that method of detecting the second key press.

     

    (1) The first thing the macro does is find the previous date/time that it ran, which should have been stored in a text file.  If the file doesn't exist, a dummy (very old) date/time is used instead.  (Could have stored date/time in an environment variable, registry key, or whatever, but text files are easy.)

    (2) Current date/time of this execution is obtained, and stored in the text file (for next time).

    (3) If current date/time is more than 1/2 second after previous run time, macro types the close application sequence.  If within 1/2 second, type "n" so changes won't be changed. 

     

    // Get previous execution time of this macro from file if file exists
    // If file does not exist, make up a very old time for previous execution
    If File Exists: "C:\Temp\Date_Time_Macro_String.txt"
      Variable Set String set %PREVIOUS_STRING_DATETIME% to the contents of C:\Temp\Date_Time_Macro_String.txt
      Variable Modify String %PREVIOUS_STRING_DATETIME%: Convert to Decimal (%PREVIOUS_DECIMAL_DATETIME%)
    Else
      Variable Set String %PREVIOUS_STRING_DATETIME% to "111.111"
      Variable Modify String %PREVIOUS_STRING_DATETIME%: Convert to Decimal (%PREVIOUS_DECIMAL_DATETIME%)
    End If

     

    // Current date/time into file
    Date/Time: Set %DATETIME% to the current date/time
    Convert Date/Time to Decimal: %DATETIME% => %DECIMAL_DATETIME%
    Variable Modify Decimal %DECIMAL_DATETIME%: Convert to Text String (%STRING_DATETIME%)
    Variable Modify String: Save %STRING_DATETIME% to "C:\Temp\Date_Time_Macro_String.txt"

     

    // How long since previous execution of this macro
    Variable Modify Decimal: %TIME_DIFFERENCE% = %DECIMAL_DATETIME% - %PREVIOUS_DECIMAL_DATETIME%

     

    If Variable %TIME_DIFFERENCE% Is Less Than "0.000005787" // one-half second as a fraction of a day

     

    • Thanks 1
  6. acantor, this isn’t as socially useful as your three-liner, but it was fun and helpful:

     

    A simple macro I wrote long ago, with one keystroke (Keypad minus) closes the current application, usually by
        Text Type (Simulate Keystrokes): <ALTD><SPACE>c<ALTU>
    In browsers and in the Adobe Reader it will close only the current browser tab or PDF if more than one is open, otherwise closes the whole thing.

     

    But a very useful change added recently involves closing without saving changes.  For example, I plug some trial numbers into a spreadsheet to see their effect, but don’t want to save the changes.  Or maybe I edit a Word document but decide to scrap the changes because they are not up to my usual Shakespearean standards.  So when I trigger the “close” macro the application doesn’t close, but instead pops up a box asking if I want to save my changes.  Then I have to move from keyboard to mouse to click “No”, or reposition my hands on the keyboard to type “n”.  

     

    Seems trivial, but it’s a pain and I’m impatient.  So I changed my “Close” macro so if it runs twice within 1/2 second, the second execution types “n” instead of <ALTD><SPACE>c<ALTU>.  If I tap the hot key once, it is a normal close.  If I tap it twice rapidly, it closes and types "n" to scrap the changes.  

     

  7. The macro logic looks correct to me.  Whether it stops or continues depends on the values of T3 and T4 when the "IF" command.  That's why I suggested inserting a Text Box Display before the "IF", to determine exactly what the variables contain at that point. 

     

    How soon does the screen change after the macro types T1 and ENTER?  Maybe you need a delay longer than 1000ms at that point, to make sure the application has had enough time to change the URL when the number is correct. 

  8. I don't understand how it can work if you type <ALT>d<

    On my PC, typing <ALT>d highlights the URL, then typing the < character causes the entire highlighted URL to be replaced by < and the single character < is loaded into the clipboard.

     

    Should have the Sound Beep command before the Macro Stop.

     

    Other than that, I can't see where the problem is. 

    For testing, try a Text Box Display just before the compare of T3 with T4.  Put some kind of brackets around the displayed variables so you can tell if there are invisible blanks or nulls at beginning or end of the variables.  That could make them appear unequal.

     

    For example, in the Text Box, display

    ***%T3%***

    ***%T4%***

  9. I don't think you can use controls on a web page.  There are no "standard" or "pre-set" variable names -- you make up your own.  The following sequence of macro commands are approximately what should work.  You may need some Delay commands as the web page changes, to keep the macro from outrunning the screen.

     

    Variable Set String %expected_URL% to 'xxxxxx' -- this is the number you expect (hope) to see in the new URL

    Text Type Alt-d to highlight the actual URL at the top of the browser page

    Text Type Ctrl-c to copy the highlighted URL text into clipboard

    Variable Set String [set value from clipboard] -- you can make up any variable name you want, for example %URL_Name%

    If Variable %URL_Name% Contains %expected_URL%

    . . . .

    . . . .

     

     

     

  10. 1 hour ago, azdayton said:
    • I run the macro.  It STILL says 3.
    • I restart Macro Express.
    • I run the macro.  Now it says 2.

     

    Suggestions:

     

    Contact Insight and report it as a bug, see what they have to say.  The Macro Explorer menu has a Help selection, and under that is "Online Support" which allows you to report bugs. 

     

    Worst case while waiting for an Insight response -- give your users a macro that runs the Restart Macro Express command, and tell them to use it whenever they change monitors.

     

    P.S. What version of ME are you using?  Strange that acantor's macro works for him but not for you.

  11. 34 minutes ago, koden said:

    Only very few times it fails in a TAB sequense, because of a lack or whatever.

     

    I'm glad it works more reliably now.

    If you have not already done so, look at the "Keystroke Speed" command.  Slowing the keystrokes a little might help with the TAB sequences.  I routinely put this command at the beginning of macros, and the typing is still fast enough for most purposes.  There is a similar Mouse Speed command.

     

    Keystroke Speed: 30 milliseconds

     

  12. 8 hours ago, koden said:

    maybe because of lack in connection to website or something else.

    The macro then itself stops, because there is something not there as expected.

    In that place I assume it's more difficult then?

     

    In addition to the "Script Error" window that I mentioned above, most macro commands have an "On Error" tab.  Look at the Help screens for "on error" or "catch error".  In most cases, it's probably just as easy to play your sound when "Script Error" appears, because you only have to write the single macro triggered by the window title, rather than do special coding for every possible error. 

    ScreenCapture_10_27_2022_8_57_33.jpg

  13. If there is logic in your script that determines the macro should stop for an error, then you could play a sound file at that point -- see screen shot below.

     

    Sometimes (always??) an unexpected error will pop up a "Script Error" window -- the one you don't want to watch for.  So you could write a small macro activated by that window title, and play the sound file in that macro. 

     

    Full disclosure: I have not tried either of the above ideas, but it seems as though they should work. 

     

    ScreenCapture_10_26_2022_18_38_09.jpg.6c0cd568c30f49588aaa21b5fa2c3228.jpg

  14. Generally, yes, same logic.  Except you will need to extract more than just one digit from the end of the URL. 

    There may well be better ways to get at the URL, but I don't know them.

    I have had mixed success with WAIT FOR WEB PAGE.  I seem to recall that it is intended to work only with Internet Explorer.  I have one macro where it works very well in Firefox, but others where I have to check colors at key positions of the screen to decide whether the page has finished loading. 

  15. Well, I see acantor and I have been working in parallel, so this is kind of a repeat.  Here's the macro I just tested.  It is sloppy and slow because it relies on opening and closing Notepad on the screen.  Maybe you can figure out a way to streamline it.  

     

    Here is something that seems to work, because Notepad seems to handle your funny characters.  Assume you already have "file B" and you want to append some copied text.  Highlight the text, then trigger this macro.

     

    Delete File/Files: "c:\temp9\filea.txt"                        // delete temporary work file A
    Text Type (Simulate Keystrokes): <CTRLD>c<CTRLU>               // copy text to clipboard
    Delay: 100 milliseconds
    Program Launch: "notepad" (Normal)                             // start MS Notepad blank screen
    Text Type (Simulate Keystrokes): <CTRLD>v<CTRLU>               // paste text into Notepad      
    Text Type (Simulate Keystrokes): <ALTD>f<ALTU>a                // save Notepad as file A
    Text Type (Simulate Keystrokes): c:\temp9\filea.txt
    Text Type (Simulate Keystrokes): <ENTER>
    Text Type (Simulate Keystrokes): <ALTD>f<ALTU>x                // close Notepad
    Program Launch: "filecopy.bat" (Normal)                        // append file A from Notepad, to pre-existing file B
    Macro Return


    Batch file "filecopy.bat", launched by the macro, consists of the old-fashioned DOS command
    Copy c:\temp9\fileb.txt +  c:\temp9\filea.txt  c:\temp9\fileb.txt

     

×
×
  • Create New...