Jump to content
Macro Express Forums

rberq

Members
  • Posts

    1,200
  • Joined

  • Last visited

  • Days Won

    61

Posts posted by rberq

  1. 8 hours ago, calee said:

    Can a macro somehow capture what is scanned (it probably pops up on the screen for 1 second before the order pops up.

     Is the scanned data recorded in a file on the PC -- ideally, a txt file log?  If so, a macro triggered by the order screen could read the last record of the file and check its contents.

     

    Does the scanned-data pop up screen have a title that could trigger a macro? 

  2. 8 hours ago, calee said:

    ... I can see the full title on the window title bar in the program ...

     

    Can the macro highlight the entire screen (Ctrl-a) or part of it, copy it into the clipboard and then into a variable, and parse out the information from there?  It looks a little sloppy to the user but I have been able to use the technique successfully a number of times.  Generally I click in an unused but relevant part of the screen, type Ctrl-a to highlight, copy to clipboard, and click a second time to clear the highlighting.  

  3. I know these aren't real lengths, but:

     

    If for example the window title is
    ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
    and you are concerned with 56789
    but Macro Express will only activate on the first 20 characters
    ABCDEFGHIJKLMNOPQRST
    then specify those 20 characters to activate it.  

     

    Then as the first few lines of the macro say something like
    IF WINDOW ABCDEFGHIJKLMNOPQRST IS FOCUSED
       AND
    IF WINDOW 56789 IS FOCUSED
    ELSE
    MACRO RETURN
    END IF

     

    In other words, the macro will be activated on any window title containing ABCDEFGHIJKLMNOPQRST but the logic of the macro will immediately terminate it except in the cases where you want it to continue.  I don't know if this will work for your windows, but it's easy to try with a test macro.

     

     

     

     

     

     

     

     

  4. Repeat Start (Repeat 2000 times)
      Variable Set Integer %in% to a random value between 1000 and 19999
      Variable Modify Integer %in%: Convert to Decimal (%indecimal%)
      Variable Modify Decimal: %individed% = %indecimal% / 100
      Variable Modify Decimal %individed%: Convert to Text String (%instring%)
      Variable Modify String: Append %instring% to text file, "c:\temp\numbers.csv"
      Text Box Display: Values
    End Repeat
    Macro Return

     

     

    numbers.JPG

  5. If the macro chooses random values, and if the random function works properly, then by definition statistical theory says you will get a very small percentage difference.

     

    So to more closely match real finance, I downloaded six hundred credit card charge amounts from my bank -- the most that I could access online. 

    The percentage difference was -- wait for it -- 0.020499%. 

    I thought the result might be skewed because so many items are priced as x dollars and 99 cents.  But scanning the numbers, there were few charges like that, because most purchases were not single items but a roll-up for many items. 

  6. 10 hours ago, Rick Altman said:

    do a mass dump into a CSV file, column by column?

    Macro command Variable Modify String has options that would allow you to take form data, concatenate multiple data items, and write the concatenated string to a file.  For example, with values a, b, and c from the form:

     

    //  
    Variable Set String %line% to "" // set line null

    Variable Modify String %line%: Append Text (") // line contains double-quote
    Variable Modify String %line%: Append Text String Variable (%form_data_1%) // line contains "a

    Variable Modify String %line%: Append Text (",") // line contains "a","
    Variable Modify String %line%: Append Text String Variable (%form_data_2%) // line contains "a","b

    Variable Modify String %line%: Append Text (",") // line contains "a","b","
    Variable Modify String %line%: Append Text String Variable (%form_data_3%) // line contains "a","b","c

    Variable Modify String %line%: Append Text (") // line contains "a","b","c"
    Variable Modify String: Append %line% to text file, "c:\test|filaname.csv" // write line to file
    //  

     

    Even though the last command writes to a "text" file, the fact that you use the .csv extension on the file name will make Windows, Excel, etc. consider it to be the csv file type. 

     

    • Like 1
  7. If your data is in a CSV file, it is especially easy.  (If the data is in an Excel sheet, you can save it as a CSV file, manually or as the first step of your macro.)

     

    The instructions ASCII File Begin Process and ASCII File End Process constitute a repeating loop that read the CSV file one line at a time and place that line's data into an indexed array.  

    For example, call your array "ARY".  
    If the first line of the CSV file is "a","b","c","d"
    then ARY(1)=a, ARY(2)=b, ARY(3)=c, ARY(4)=d


    Then you type or paste the array entries into the form, and continue with the next line of the CSV file.
    There is no visible jumping back and forth between the file and the form, unlike between a spreadsheet and the form, because the CSV file is not visible on the computer screen.  

     

    Macro logic is something like this:
    Open data-entry form if it is not already open

       [Beginning of loop]
    ASCII File Begin Process (file name and array dimensions are defined within this command)
    (data from one CSV line is automatically placed into array)
    Paste ARY(1) into form
    Paste ARY(2) into form
    Paste ARY(3) into form
    Paste ARY(4) into form
    ASCII File End Process (control automatically returns to do the next CSV line)

       [End of loop, falls through to next instruction after entire CSV file has been processed]
    Macro Exit

     

    • Like 1
  8. I am running MX Pro 6.6.2.1, Windows 10.  Both the Macro Explorer window and the Script Editor open as you describe.  As I recall, this behavior appeared when I updated to 6.6.2.1.  Like you, I wrote little macros to size and position them to my preferences -- in my case, full screen for both.  Previously, the windows always opened full-screen, probably because that was the size and position I had last used. 

  9. Often there is text in a button that you can search for, that gives focus to the button.  This code finds the Log Out button on a particular page and "presses" the button by typing ENTER.     

     

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

     

    Sometimes you can search for text that reliably precedes or follows the button, then tab forward or backwards to the button similar to what Cory described. 

     

  10. Above, in a macro -- works for me.

     

    Program Launch: "Excel" (Normal)
    Parameters:
    Delay: 500 milliseconds
    Text Type (Simulate Keystrokes): 12/15/2023<ENTER>
    Text Type (Simulate Keystrokes): =a1-2<ENTER>
    Text Type (Simulate Keystrokes): <ARROW UP>
    Delay: 250 milliseconds
    Text Type (Simulate Keystrokes): <CTRLD>c<CTRLU>
    Delay: 250 milliseconds
    Variable Set String %dat% from the clipboard contents
    Text Box Display: Date-%dat%

     

  11. 41 minutes ago, acantor said:

    Unless Macro Express has built-in functions that I'm not finding, it's going to be challenging to subtract from an arbitrary date. It could be a fun project, though. The logic might look something like this:

     

    acantor, I have some code that looks like yours, and it gets complex if you want it to work one-hundred percent correctly over month ends and year ends and leap years, never mind the occasional leap century.

     

    Here's a way I just tested manually.  It worked well, though visually you might not like it flashing on your screen while the macro runs:

    1- Open Excel (new, empty spreadsheet)

    2- Paste your known date into cell A1

    3- Arrow down to cell A2

    4- Type "=A1-2" and ENTER -- decrements the date by two days

    5- Arrow back up to cell A2

    6- Ctlr-c to copy the two-days-previous date into the clipboard

    7- Open Notepad and paste (or, in a macro, set a text string from the clipboard)

    8- Close Excel

     

    At least with my Excel 2010, Excel treats the mm/dd/yyyy as a date for calculation but as text when I copy to clipboard.  I haven't tried putting the above logic into a macro, but as I say, it works when I do it manually.

  12. If you are still using an old version of ME, without GOTO, perhaps you could put the whole macro (or the portion where you want to start over) in a Repeat loop.

    For example,

    SET T99 = "GO"

    REPEAT UNTIL T99 = "STOP"

    ....

    ....

    IF T7 = 2

    then open notepad and set the number 2

       ELSE

    SET T99 = "STOP"

    END IF

    END REPEAT

     

    MACRO END

     

  13. 2 hours ago, DMA said:

    <TEXT TYPE Action="1" Text="%Split[3]%"/>

     

    Try using the "Simulate Keystrokes" option of this command, rather than the "Use Clipboard and Paste" option.  See image below.

     

    Also, if you created this command with the Direct Editor, try unchecking the box for Direct Editor under "View" in the Menu bar of the Script Editor.  When I paste your command into the Editor, there is something strange about it, and it shows up as TWO separate commands.  It is generally much easier to code macros using the regular script editor rather than the Direct editor. 

     

    type.JPG

  14. 4 hours ago, tass_co said:

    However, the focus of the window may be lost when another application/notification etc. arrives and the PC may shut down before the copying/moving process is completed. Unfortunately I need to find a more stable solution.

     

    Yes, I know I said "focused" and your macro said "running".  But my point was, you could try changing your logic to avoid using the "not" condition.  See below.  

     

    Also I notice there is a blank space before the word tamamlandi -- will there ALWAYS be a blank space there?  

     

    And you might want to move the Delay before End Repeat instead of after, so as to make a less-intensive loop.  

     

    Variable Set Integer %N[1]% to 0
    Repeat Until %N[1]% Equals "1"
      If Window " tamamlandi" is running
      Else
        Variable Set Integer %N[1]% to 1
      End If
      Delay: 5 seconds     <<<<<<<<<<  Here instead of after End Repeat ???
    End Repeat
    MessageBox: PENCERE

     

  15. I am using Macro Express Pro 6.6.1.1.  I had a strange problem recently where "IF WINDOW IS FOCUSED" worked properly, but "IF WINDOW IS NOT FOCUSED" did not work.  So you could flip your logic and see if that helps. 

     

    I never did resolve whether my problem was Macro Express or just some dumb mistake by me -- I just took the path of least resistance and used the different instruction. 

     

×
×
  • Create New...