Jump to content
Macro Express Forums

rberq

Members
  • Posts

    1,201
  • Joined

  • Last visited

  • Days Won

    61

Everything posted by rberq

  1. Define an array variable rather than individually-named text variables. Increment an integer variable and use it as the index to the array.
  2. I don't know about holding a key -- can't think how that would be done. But you might be able to toggle as follows; it is essentially the same solution as you came up with in AutoHotKey. 1) User starts Macro A with a keystroke (the toggle key). 2) Macro A runs Macro B and ends itself. 3) Macro B records current mouse position (A,B) (vertical component B is all that counts). Macro B then loops continuously (Repeat loop), with a very short delay in each iteration of the loop, a few milliseconds. Each time through the loop it resets the vertical component of mouse position to whatever the starting position was. That is, if current mouse position is found to be (x,y) the macro moves the mouse to (x,B). So the user is able to move the mouse both horizontally and vertically, but the vertical movement is almost instantly cancelled by Macro B. 4) User again starts Macro A with a keystroke (the toggle key). 5) Macro A determines that Macro B is already running, and stops Macro B. Worth a try, fairly simple to code. Don’t know what impact it will have on CPU usage due to the looping – probably OK. On my PC the resulting mouse movement is kind of choppy, which may or may not be acceptable to you. Variable Set String %T1% "2" Get Mouse Position Screen: %N1%, %N2% Repeat Until %T1% = "1" Get Mouse Position Screen: %N1%, %N3% Mouse Move Screen %N1%, %N2% Delay 1 Milliseconds Repeat End
  3. I think you are almost there, but you missed the whole point of FIRST loading the entire text file into a single variable, then using a Repeat loop to process the spreadsheet rows one at a time. Here's your script modified a little: Text File Begin Process: "list-a.txt" Variable Modify String: Trim %T1% Variable Modify String: Append %T1% to %T2% Text File End Process * at this point the whole file is stacked in variable T2 Repeat Until 1=2 (in other words, repeat forever until the IF statement results in Repeat Exit) Clipboard Copy If clipboard = “” (nulls – all spreadsheet have been processed) Repeat Exit End If Variable Set String %T3% from Clipboard Variable Modify String: Trim %T3% If Variable %T2% contains variable %T3% Text Type: <ARROW RIGHT><DELETE><ARROW RIGHT><DELETE><ARROW RIGHT><DELETE><ARROW RIGHT><DELETE><HOME><ARROW DOWN> Else Text Type: <ARROW DOWN> End If Repeat End
  4. I think this approach will work: Use Text File Begin Process, once only, to load all entries from the file into a single text variable. That is, read the file one line at a time into T1, trim, and append its 9 characters to T2 (variable modify string/append), continue until the whole file has been loaded. When done, T2 will be an array of 9-character strings. (But you won’t need to process it as an array – see below.) Next, copy the first spreadsheet cell into the clipboard, store in text variable T3. Command If Variable %T2% contains "%T3%" tells you whether the array (file) contains that cell’s data, and you can type or delete into other cells in the row as desired. Text Type of arrow keys is good for moving from one spreadsheet cell to another. Get this working for a single row of the spreadsheet. Once you have it working for one row, add Repeat Start and Repeat End to handle all the rows one by one. Use Repeat Exit when you reach the end of the spreadsheet (that is, when copy to clipboard finds nothing).
  5. Repeat Start (Repeat 20 times) Control Key Down Text Type: c Control Key Up ... ... ... Alt Key Down Text Type: <TAB> Alt Key Up Repeat End You might also try repeating indefinitely -- or repeat an extremely high number of times. Then after the copy-to-clipboard (Ctrl-c), if the clipboard contains nothing, exit from the repeat loop. That way your macro would deal automatically with a variable number of entries in a column, as long as the last cell in the spreadsheet column is followed by a null cell. Variable Set Integer %N1% to 1 Repeat Until %N1% <> 1 Control Key Down Text Type: c Control Key Up If Clipboard Text Equals "" Repeat Exit End If ... ... ... Alt Key Down Text Type: <TAB> Alt Key Up Repeat End
  6. Usually, variable names bracketed by % can be substituted for literals. So instead of this: If Variable %LOOP[1]% Equals "2" Variable Modify Integer set %XCOORD[2]% to the contents of %TEMP[1]% try this: Variable Modify Integer set %XCOORD[%LOOP[1]%]% to the contents of %TEMP[1]% The script editor allows it, so it probably will work. I hope so -- gets rid of all the IFs -- way more elegant.
  7. I would tell you how to put values into an array, but I use Macro Express Version 3 which doesn't have arrays. My guess would be, define an integer variable, increase it by one (Variable Modify Integer) each time through the Process loop, and use the variable as the index to the slots in the array.
  8. To ignore lines starting with 5, use an IF command. Text File Begin Process: C:\1_temp\MouseRecorderPro2.txt IF FIRST BYTE OF LINE IS NOT = 5 Variable Set Integer %N[1]% to the position of "X" in %COORD[1]% Variable Modify Integer: %N[1]% = %N[1]% + 2 Variable Modify String: Copy a substring in %COORD[1]%, starting at %N[1]% and 4 characters long to %TRIMX[1]% Text Box Display: ENDIF Text File End Process Always copy 4 characters then VARIABLE MODIFY STRING (RIGHT-TRIM). That will get rid of the trailing space if it turns out to be only 3 digits. If it is 4 digits the trimming will have no effect.
  9. * Example of one line of data, in variable T1. In your macro the Text File Process will populate the text variable, rather than the Set String command. Variable Set String %T1% " X:1701 Y:580" * Set integer to position of "X:" within the data Variable Set Integer %N1% from Position of Text in Variable %T1% * Bump position up by 2 characters so N1 is pointing to the first digit instead of to "X:" Variable Modify Integer: %N1% = %N1% + 2 * What Cory said -- move four digits from the data to another variable Variable Modify String: Copy Part of %T1% to %T2% [starting position N1, number of digits 4] * Display the extracted digits to verify the extraction is working properly Text Box Display: %T2% Of course in your actual macro, you would move the extracted digits to the array instead of Text Box Display.
  10. I have done it only by installing Macro Express on the remote PC. Except in the case of some Citrix applications running on a server, when the macros were installed only on my local PC.
  11. Not really a sledgehammer, just working intelligently with the tools the scripting language makes available to you. And look how well you understand Macro Express's date abilities now. Next thing to do is put this code into a separate macro that you can run (call) from other macros, rather than have to recreate the process every time you want to use it.
  12. I have done Cory's technique, but saving in an environment variable rather than registry. The only problem I ran into was exceeding the allowable size of an environment variable. I don't know if you have to watch out for size limits with registry keys.
  13. The script I gave you in a previous post was for Macro Express Version 3. The one below is almost identical, but for ME Pro. The problem of fractional days is avoided, by converting the current-adjusted-date to a text string of format m/d/yyyy before comparing it to the future date. Again, variable %N[1]% contains the number of days difference when the macro ends. There is probably another way to cope with the fractional days, but this method works fine for small date differences. It may take an unacceptably long time to process if you are dealing with dates that are years apart. Variable Set String %T[2]% to "5/24/2017" [future date] Variable Set Integer %N[1]% to -1 Repeat Until %T[1]% Equals "%T[2]%" Variable Modify Integer %N[1]%: Increment Date/Time: Set %DT[1]% to an adjusted date/time [adjust current date forward by N[1] days] Variable Modify Date/Time: Convert to Text String [convert adjusted date to m/d/yyyy format] End Repeat Text Box Display: %N[1]% .... %T[1]%
  14. P.S. Understand that your football and our football are two different things, and different levels of violence.
  15. I use Macro Express 3, and have had little luck with date manipulation. Here’s a clever method, if I do say so myself. Use the Date/Time command in a Repeat loop until the “adjusted” date (based on today) matches the future date. When the loop ends, variable N1 contains the number of days difference between today and the future date. // Variable Set String %T2% "12/23/2017" [future date] Variable Set Integer %N1% to -1 [initialize as negative 1 to allow for future date = today] Repeat Until %T1% = %T2% [repeat until computed date = future date] Variable Modify Integer: Inc (%N1%) [increment N1 by 1 each time through loop] Date/Time: Save "M/d/yyyy" into %T1% Repeat End Text Box Display: %N1% [number of days between current and future date] // This is what the Date/Time command should look like:
  16. Variable Set Integer %N1% from Position of Text in Variable %T1% [search for the "-"] Variable Modify String: Copy Part of %T1% to %T2% [copy from position 1 to position %N1%] Variable Modify String: Save %T2% to Clipboard
  17. From your initial post, I thought you wanted the macro to continue sooner after starting Excel -- not have Excel start sooner. Big difference.
  18. No. I mean make a batch file to start Excel, then start the batch file from your macro like this:
  19. If the text box display is the first line of the macro, and is not appearing, then it sure sounds like the macro is not running at all. Check the macro's Scope tab to make sure it is Global -- not restricted to a particular window or program.
  20. What does "can't get it to do anything" mean??? Does it pop up the text box, or not??? Try starting the macro with one of the keypad characters, for example the asterisk or the + key. As Sam asked, what application are you typing into? I have seen some applications that "trap" or "block" the Ctrl key so a macro triggered by a Ctrl combination does not run at all, because ME never sees the key combination intended to start the macro.
  21. Or (similar to what Acantor (a singer???) is saying): make a bat file to start Excel; containing just the lines start c:\path\excel.exe and exit Then have your macro launch command.com with parameter /c batchfile.bat Presumably the delay will only be for the time it takes command.com to run -- not long. Worth a try.
  22. To sort of simulate your situation, I ran the following test macro: Variable Set Integer %N1% from Current Second Program Launch: "notepad" Variable Set Integer %N2% from Current Second Text Box Display: %N1% %N2% The time difference between N1 and N2, over many tests, was almost two seconds. So I am seeing delays like you describe. Can't explain it, but yes I see similar behavior to what you see. You are seeing 5 seconds, I am seeing two, but then I am starting a simpler application. If I remove the Program Launch command from my test macro, the times displayed are always identical. I would guess -- GUESS, mind you -- that ME is being a responsible Windows citizen, asking Windows to launch the application and then waiting patiently for an "all done" acknowledgement from Windows, which is some time in coming. Sorry, kind of imprecise for a technical answer, but that's the best you will get out of me.
  23. Hmmmmm. Things are looking clearer now. Notepad saved the original file as Unicode, but ME adds ANSI (non-unicode) characters. If you then open the file with Notepad specifying Unicode encoding it looks funny (Chinese). If you specify ANSI when opening it, not quite so funny; the original data has two bytes per character (Unicode), and the appended data looks fine, only one byte per character. ÿþa b c d e f g A B C D E F G abcdefgABCDEFG If you run the macro with the file not existing at all, then it is created as ANSI and the appended data is ANSI and everything looks fine. abcdefgABCDEFG If you create the file from scratch with Notepad and specify ANSI when you save it, then run the macro, everything looks fine. Variable Set String %T1% "abcdefgABCDEFG" Variable Modify String: Append %T1% to Text File abcdefgABCDEFGabcdefgABCDEFG
  24. Never mind. I thought you were doing a late April Fool's joke, but mine does the same thing. Using ME version 3.9.0.1. With Notepad I loaded "abcdefgABCDEFG" into a file, then ran these two macro instructions. Results below. I don't know if it's Chinese or Martian characters, but there it is. Variable Set String %T1% "abcdefgABCDEFG" Variable Modify String: Append %T1% to Text File abcdefgABCDEFG扡摣晥䅧䍂䕄䝆਍
  25. So show us the content of the text variable being appended, and the command(s) used to do the appending. And attach a screen shot of the text editor screen showing the result.
×
×
  • Create New...