Jump to content
Macro Express Forums

rberq

Members
  • Posts

    1,195
  • Joined

  • Last visited

  • Days Won

    61

Everything posted by rberq

  1. Here's a variation on acantor's idea: Insert a "Label" statement just before or after the Text Box Display, and include the label name in the header and/or text of the box. No matter how much macro code is added or removed, you can find the label using the Script Editor. // :abc // Label abc Text Box Display: abc //
  2. Repeat Start (Repeat 10 times) Text Type (Simulate Keystrokes): <ARROW DOWN> Delay: 10 milliseconds End Repeat Has the advantage that you don't have to count how many you have put in the command. And easy to change just by modifying the Repeat command. Delay may or may not be needed depending on the application you are interacting with.
  3. 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
  4. I cheated, because I wanted to use real-world values. I was surprised that my real numbers had the same tiny discrepancy as your Monte Carlo simulation.
  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. 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.
  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
  8. "A foolish consistency is the hobgoblin of little minds" (Emerson) "But it has its comforts" (me)
  9. 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.
  10. 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.
  11. 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%
  12. 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.
  13. Just a shot in the dark -- do you have a command like this Keystroke Speed: 30 milliseconds at the beginning of your macro? It may be that the "typing" is over-running the application -- characters being presented faster than the application can absorb them. Edit: My posting overlapped with acantor. But I see we are thinking along the same lines.
  14. 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
  15. The newer versions of Macro Express Pro have a LABEL statement and a GOTO command. I think that will let you do what you want.
  16. 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.
  17. 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
  18. 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.
  19. Damn! And it took me an hour to NOT figure that out! Good catch.
  20. Your code looks fine, but I played with it for an hour and got the same result you did, or even stranger. Whatever was in the clipboard before is what gets pasted. I even replaced CONTROL-x with CONTROL-c followed by DELETE -- which should be the same thing -- but it didn't help. Also eliminated the uppercase conversion, to see if it would re-paste the original character, but still no good. Longer delay times were no help. If I do the keystrokes manually the process works, but of course with no upper case conversion. I'm wondering if the CONTROL-ARROW sequences are somehow bothering Macro Express, but I haven't tested for that. Puzzled!
  21. Yes, I have had the same problem where web sites screw up my code with their silly changes. I will keep the elements thing in mind and maybe try it on a couple sites. I seldom if ever use Chrome, so I wonder if similar techniques can work on Firefox.
  22. Interesting. I was not aware of Chrome elements. I played with a National Weather Service page on Chrome, and was able to navigate to a "location" entry field and set focus to the field using your technique. It's unclear to me why I would use elements instead of just "<CTRLD>f<CTRLU>location" on the visible web page. Apparently this and other element features would be useful to developers??? I'm afraid I am in over my head ....
  23. I believe an integer variable will have the value zero if there have been no previous commands setting a value. Therefore N2 will NEVER be equal to 1, and the macro will NEVER set N1 to a random value -- at least the way the macro stands now. If you PREVIOUSLY set N2=1, and saved and restored variables every time the macro ran, then N2=1 would be true once and only once, and "never" again. But shutting down and restarting Macro Express would wipe out saved variables and you would be back to the original state where N2 will NEVER equal 1. And some unrelated macro, assuming you have some, could change the value of N2, then save variables, and this macro would pick up that saved value, whether it be 0 or 1 or 987654. Try making a second macro whose only function is to set N2=1 and save variables. Run that macro once at the beginning of each day, and I think it will make the random feature work the way you want it to.
×
×
  • Create New...