Jump to content
Macro Express Forums

stevecasper

Members
  • Posts

    570
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by stevecasper

  1. A little bit. You'll need to establish some logic with regards to the numbers being saved/retrieved from the Random Number file. When I get a few minutes I'll play with it and see what I can do.
  2. %HOMEDRIVE% is probably your C: drive, though it could be different. I honestly don't know how to change it... I just know that at home, it is my C: drive, but at work it is my H: drive. You're welcome to change the path to anything you want. The macro command itself has a Browse button so you can browse to the exact folder you want the file to be created in. I just used the %HOMEDRIVE%%HOMEPATH% text to make the macro immediately useable for anybody who copied the script directly into a new macro. The file name is Random Number, yes. Note that I did not add an extension (like .txt). So the file may not show up if you browse down the path. You can change the macro to create the file as Random Number.txt if you would like. It will not affect the macro's performance either way.
  3. I have several macros that open a text box and update its contents periodically. Whenever these text boxes are open, my other macros lag and hang, becoming inefficient. Has anybody else noticed similar problems? As an example: Macro 1: Read Registry Value to %TVariable% Text Box Display: %TVariable% Repeat Until %T1%<>%T1% Read Registry Value to %TVariable% __Update Text Box Delay: 5 seconds Repeat End Macro 2: //At some point there may be cause to write a different value to the Registry Value being read in Macro 1. While the text box from Macro 1 is displayed, Macro 2 drags and drags. The information in the Registry Value is important. It's useful to have it visible while processing my work. I have considered utilizing a notepad for this, but I can't make a Notepad stay visible. Of course, with the Text Box Update, I can keep it on top without keeping focus, but that doesn't stop it from regaining focus when it updates. So I'm having to deal with the little problems that that causes to some of my other processes, but I just really thought having the Text Box Display/Update would be more fun than a boring old notepad stuffed in a corner. I don't know if the problem is universal, or specific to my crappy work PC. I haven't tested it on my home PC, yet. I may do that tonight or maybe sometime over the weekend.
  4. Here is the Light Version. You can still choose what the Max will be (though I've removed the prompt, so you'll need to establish the maximum within the Variable Set Integer %N3% command). I don't know what your default folder is. It depends on your user profile, I believe. On my home computer %HOMEDRIVE%%HOMEPATH% is the "Steven" folder on my desktop; at work it is simply H:/ . It will be something different on your computer. You can figure out exactly where by building a simple macro like this one: (this is the Direct Editor text... that's how simple this macro is) <LAUNCHDEL2:0:01%HOMEDRIVE%%HOMEPATH%> This macro (the one that makes sure the random number does not repeat) does leave a file behind (it has to in order to make certain the comparisons are consistent). You can delete the file manually, or you can build a second macro with the following code to find it and delete it: Again, this is just Direct Editor script: <DOFILE:08:NN:%HOMEDRIVE%%HOMEPATH%/Random Number>> And now, what we've all been waiting for, the Light Version: // %N1% Random Number // %N2% Previously Generated Random Number // %N3% Maximum Value of Randomly Generated Number // %T1% Text Variable Used to Facilitate New and Old Number Comparisons // %HOMEDRIVE%%HOMEPATH% - Essentially represents C: Drive and your default folder. // This may be different for every computer, so I used these defaults because they should work for anybody. Variable Set Integer %N3% to 10 Repeat Until %T1% <> %T1% If File Exists "%HOMEDRIVE%%HOMEPATH%/Random Number" Variable Set String %T1% from File: "%HOMEDRIVE%%HOMEPATH%/Random Number" Variable Modify String: Convert %T1% to integer %N2% Else Variable Set Integer %N2% to %N3% Variable Modify Integer: Inc (%N2%) End If Variable Set Integer %N1% with a Random Number If Variable %N1% <> variable %N2% Variable Modify Integer: Convert %N1% to text string %T1% Variable Modify String: Save %T1% to Text File Break End If Repeat End Text Box Display: This Text Box Represents The Rest of Your Macro <REM2:%N1% Random Number><REM2:%N2% Previously Generated Random Number><REM2:%N3% Maximum Value of Randomly Generated Number><REM2:%T1% Text Variable Used to Facilitate New and Old Number Comparisons><REM2:%HOMEDRIVE%%HOMEPATH% - Essentially represents C: Drive and your default folder.><REM2:This may be different for every computer, so I used these defaults because they should work for anybody.><IVAR2:03:01:10><REP3:08:000002:000001:0001:1:01:T1><IFOTH:01:2:%HOMEDRIVE%%HOMEPATH%/Random Number><TVAR2:01:04:%HOMEDRIVE%%HOMEPATH%/Random NumberT><TMVAR2:05:01:02:000:000:><ELSE><IVAR2:02:01:%N3%><NMVAR:08:02:0:0000001:0:0000000><ENDIF><IVAR2:01:06:%N3%><IFVAR2:5:01:2:N2><NMVAR:05:01:0:0000001:0:0000000><TMVAR2:17:01:00:000:000:%HOMEDRIVE%%HOMEPATH%/Random NumberF><BREAK><ENDIF><ENDREP><TBOX4:T:1:CenterCenter000278000200:000:This Text Box Represents The Rest of Your MacroCurrent Number: %N1%> And yes, you may remove the final Text Box display... it's just there to let you know where to add the rest of your macro.
  5. I'm a sucky lick-spittle, what can I say. Hmmm... You were quicker on the draw than I was (in fact I've noticed you to be quicker than me on a number of occasions) at the beginning of this thread. And after Cory's recent embarrassing admissions, I would dare-say you are now king of Macro Express. How's that? Probably too much sarcasm... I don't actually find Cory's admissions embarrassing. I could barely follow them. So if you at least could empathize with Cory on how overwhelming learning VB is/can be, then you are doing better than me. I believe VB stands for Visual Basic, but I honestly thought VB, VBA and VBScript were all just terms for the same basic thing. And PASCAL? Seriously? I mean, I learned a smattering of BASIC to make silly little Zork-style programs on my family's TI (closest thing we had to a home computer until the mid '90s) when I was 8 or 9 (Note: I had no idea what Zork was at that time). Then in Jr. Highschool I took a computer programming class (this was '89-'90) where we re-hashed the BASIC I already knew and nothing more, though I did learn about pixels and how to program frighteningly-archaic pictures by coloring pixels in specific points - Let's just say that PacMan had better graphics than anything I could have programmed at that point. Anyway, I figure if nothing else, everybody's ego can be boosted by comparing their skills to my remedial programming expertise.
  6. I have what I believe to be a working model for your macro. That is weird. I haven't noticed that, myself, but I don't work with randoms very often. My wife is a highschool Mathematics and Statistics teacher, and she has told me that not even computers have the capacity to generate completely random sequences. An underlying pattern always emerges. Of course, I argue that true randomness will always generate the appearance of a pattern. They say if you give a monkey a typewriter and infinite time, and he will eventually produce the complete works of Shakespear - I think that's false, because the monkey will likely develop a preference for a specific key. However, if you replace the monkey with a computer typing randomly for infinite time, you will end up with the complete works of Shakespear (and everything else ever written - or that ever will be written - by man... and probably some really good recipes, too). With that said, if you think there is a definite problem with the randomness of the program, I'd suggest contacting ISS support directly. Now, on to the fun. This macro is a bit longer than I had expected, but still very reasonable. The prompts at the beginning can be removed, as long as you know you will always use the same minimum and maximum numbers. Just set N4 to you standard minimum and N3 to your standard maximum and remove the prompts. // %N1% Random Number // %N2% Previously Generated Random Number // %N3% Maximum Value of Randomly Generated Number // %N4% Minimum Value of Randomly Generated Number // Note: The Random Number Generator has a minimum default of 0 wich cannot be changed. // __Because of this, we have to manipulate the values of %N1% and %N3% // __I will set these manipulations apart in the body of the text with surrounding *** Remarks // __When N1 is generated it could = 0. If the min is set at 1, then N1 must be increased // __by the value of N4 (in this case, 1) in order to ensure N1 >= 1. // __If the max (N3) is 10, then increasing N1, could result in N1 > N3 (which we must avoid.). // __So we start by reducing N3 by the value of N4 to ensure that when N1 is increased, // __N1 does not exceed N3. // %T1% Text Variable Used to Facilitate New and Old Number Comparisons // %HOMEDRIVE%%HOMEPATH% - Essentially represents C: Drive and your default folder. // This may be different for every computer, so I used these defaults because they should work for anybody. Variable Set Integer %N4% to 1 Variable Set Integer %N4% from Prompt Variable Set Integer %N3% to 10 Variable Set Integer %N3% from Prompt // *** Variable Modify Integer: %N3% = %N3% - %N4% // *** Repeat Until %T1% <> %T1% If File Exists "%HOMEDRIVE%%HOMEPATH%/Random Number" Variable Set String %T1% from File: "%HOMEDRIVE%%HOMEPATH%/Random Number" Variable Modify String: Convert %T1% to integer %N2% Else Variable Set Integer %N2% to %N3% Variable Modify Integer: Inc (%N2%) End If Variable Set Integer %N1% with a Random Number // *** Variable Modify Integer: %N1% = %N1% + %N4% // *** If Variable %N1% <> variable %N2% Variable Modify Integer: Convert %N1% to text string %T1% Variable Modify String: Save %T1% to Text File Break End If Repeat End Text Box Display: This Text Box Represents The Rest of Your Macro <REM2:%N1% Random Number><REM2:%N2% Previously Generated Random Number><REM2:%N3% Maximum Value of Randomly Generated Number><REM2:%N4% Minimum Value of Randomly Generated Number><REM2:><REM2:Note: The Random Number Generator has a minimum default of 0 wich cannot be changed.><REM2:__Because of this, we have to manipulate the values of %N1% and %N3%><REM2:__I will set these manipulations apart in the body of the text with surrounding *** Remarks><REM2:__When N1 is generated it could = 0. If the min is set at 1, then N1 must be increased ><REM2:__by the value of N4 (in this case, 1) in order to ensure N1 >= 1.><REM2:__If the max (N3) is 10, then increasing N1, could result in N1 > N3 (which we must avoid.). ><REM2:__So we start by reducing N3 by the value of N4 to ensure that when N1 is increased, ><REM2:__N1 does not exceed N3.><REM2:><REM2:%T1% Text Variable Used to Facilitate New and Old Number Comparisons><REM2:%HOMEDRIVE%%HOMEPATH% - Essentially represents C: Drive and your default folder.><REM2:This may be different for every computer, so I used these defaults because they should work for anybody.><IVAR2:04:01:1><IVAR2:04:02:FWhat is the minimum random value?FFCenter:Center><IVAR2:03:01:10><IVAR2:03:02:FWhat is the maximum random value?FFCenter:Center><REM2:***><NMVAR:02:03:1:0000003:1:0000004><REM2:***><REP3:08:000002:000001:0001:1:01:T1><IFOTH:01:2:%HOMEDRIVE%%HOMEPATH%/Random Number><TVAR2:01:04:%HOMEDRIVE%%HOMEPATH%/Random NumberT><TMVAR2:05:01:02:000:000:><ELSE><IVAR2:02:01:%N3%><NMVAR:08:02:0:0000001:0:0000000><ENDIF><IVAR2:01:06:%N3%><REM2:***><NMVAR:01:01:1:0000001:1:0000004><REM2:***><IFVAR2:5:01:2:N2><NMVAR:05:01:0:0000001:0:0000000><TMVAR2:17:01:00:000:000:%HOMEDRIVE%%HOMEPATH%/Random NumberF><BREAK><ENDIF><ENDREP><TBOX4:T:1:CenterCenter000278000200:000:This Text Box Represents The Rest of Your MacroCurrent Number: %N1%>
  7. You can delete or disable the command lines you don't want (i.e. the Text Box Display commands). If I understand you correctly, you want the following: You run the macro. The macro generates a random number. The macro does something with that number. The macro ends. You run the macro again. The macro generates a new number which does not match the previous number. The macro does the same thing it did the last time you ran the macro. The macro ends. When I get a few minutes today, I'll tweak my macro above to do just this. In the mean time, I recommend you take my macros and play with them a bit. Tweak them on your own, and get a feel for how they work. It's really the best way to learn how to build your own. I'll be back in a little while with an example of how to do what I've understood you to need.
  8. If the Control is recognized by Macro Express, then you can use the Mouse Click in Control command. Then you can use a Text Type: Ctrl+A to highlight the contents of the control (you could also probably double-click within the control, rather than use Ctrl+A). Clipboard Copy command. Set Variable to contents of clipboard. Unless the Control is a button, this should work.
  9. Well after all that work, I just realized you don't mind if numbers repeat. You just don't want them to repeat twice in a row. Whoops! Still, based on the macros I built, it should be simple enough to figure out how to make basic comparisons to make sure two numbers aren't provided twice in a row. Should also minimize lag Sorry about that! EDIT This is closer to what you wanted, I believe. Variable Set Integer %N1% to 10 Variable Set Integer %N1% from Prompt Repeat with Variable using %N1% Variable Set Integer %N1% with a Random Number Variable Modify Integer: Convert %N1% to text string %T1% If Variable %T2% <> variable %T1% Variable Modify String: Copy %T1% to %T2% Variable Modify String: Append "%T1% " to %T3% Text Box Display: %T1% Else End If Repeat End Text Box Display: All Generated Numbers <IVAR2:01:01:10><IVAR2:01:02:FHow many numbers do you need generated?FFCenter:Center><REP3:05:000001:000001:0001:0:01:><IVAR2:01:06:10><NMVAR:05:01:0:0000001:0:0000000><IFVAR2:4:02:2:T1><TMVAR2:09:02:01:000:000:><TMVAR2:07:03:00:000:000:%T1% ><DIS:<TBOX4:T:1:CenterCenter000278000200:000:%T1%Your randomly generated number is: %N1%><ELSE><ENDIF><ENDREP><TBOX4:T:1:CenterCenter000278000200:000:All Generated Numbers%T3%>
  10. Ok, so I like a challenge. Here are two macros that both do what you want. The first one is very basic, so you can pick it apart easily and see how it's done. The second one is arguably better. It's much more complex, and allows you to select the maximum value of your random generator from a prompt. For both of these macros, I've set the default maximum to 10, and left the default minimum at 0. Mathematically, that leaves 11 possible numbers that could be generated. Please keep in mind, that as you start running out of numbers, the macro may lag as it ignores previous results and tries again. Theoretically, this lag could last forever. Because of that, the 2nd macro has a built-in "escape". After 100,000 failures, you'll get a pop-up asking you if you want to continue. If you say Yes, it will try again, up to 100,000 more times, before prompting you again. With only 11 numbers to choose from, you'll see that pop up a surprising number of times when you get down to only 1 or 2 numbers left. I tested this macro with 101 possibilities. The 100,000 Failures error began in the early 70s and by 88 was happening very frequently. Anyway, here are the two macros. I'm providing both Scripting Editor and Direct for the simple one. The complex one will only have Direct Editor. Repeat Until %T1% <> %T1% Variable Set Integer %N1% with a Random Number Variable Modify Integer: Convert %N1% to text string %T1% If Variable %T2% does not contain variable %T1% Variable Modify String: Append "%T1% " to %T2% Text Box Display: %T1% Else Text Box Display: No Unique Number Generated End If Repeat End <REP3:08:000002:000001:0001:1:01:T1><IVAR2:01:06:10><NMVAR:05:01:0:0000001:0:0000000><IFVAR2:4:02:8:T1><TMVAR2:07:02:00:000:000:%T1% ><TBOX4:T:1:CenterCenter000278000200:000:%T1%Your randomly generated number is: %N1%><ELSE><TBOX4:T:1:CenterCenter000278000200:000:No Unique Number GeneratedNumbers generated so far: %T2%><ENDIF><ENDREP> Complex Macro: <IVAR2:02:01:10><IVAR2:02:02:FWhat is the maximum value?FFCenter:Center><TVAR2:04:01:all><REP3:08:000002:000001:0001:1:01:T1><NMVAR:01:06:1:0000002:2:0000001><IVAR2:01:06:%N2%><NMVAR:05:01:0:0000001:0:0000000><IFVAR2:4:02:8:T1><TMVAR2:07:02:00:000:000:%T1% ><TBOX4:T:1:CenterCenter000278000200:000:%T1%Your randomly generated number is: %N1%><IVAR2:07:01:0><ELSE><TMVAR2:09:03:02:000:000:><TMVAR2:21:03:01:000:000: ><IVAR2:03:12:3><IVAR2:04:12:2><NMVAR:02:03:1:0000004:1:0000003><REP3:01:000001:000001:10000:1:05:><IFVAR2:2:07:1:100000><IFMESS3:00000:1:1:%N7% FailuresYou've generated %N3% of %N6% possibilities. Further unique selections from this sample may be delayed indefinitely. Would you like to continue?000529:000433><IVAR2:07:01:0><ELSE><IVAR2:07:01:%N3%><NMVAR:01:03:1:0000002:1:0000002><TVAR2:04:01:%N7%><BREAK><ENDIF><ENDIF><IFVAR2:2:05:1:10000><NMVAR:01:07:1:0000005:1:0000007><ENDIF><ENDREP><IFVAR2:5:03:4:N2><BREAK><ENDIF><ENDIF><ENDREP><TBOX4:T:1:001781Center000344000200:000:That Should Be ItYou've generated %T4% of the numbers between 0 and %N2% %T2%>
  11. I'm assuming you're using the Set Integer To A Random Value command. My first instinct is to tell you to modify the N variable (converting to Text String). Do this each time a random number is generated, and append each one to a separate text string (be sure to include a space after each number appended). Now use an If Variable Contains command to determine if the number has already been used. If so, you have the Set Integer command try again and again until it selects a value not yet used. There might be a simpler way, but this is what came to mind first.
  12. I don't begrudge you your ego, as far as ME is concerned, I think you've earned it. Frankly, I was a little doubtful that I had discovered an actual flaw in your code. In fact, I didn't think it was a flaw, so much as a simplified version of what would actually be needed. Which you have just pointed out, in a sense, that it was. Your code was also much more in line with what Terry was actually trying to accomplish, so you offered up a more appropriate nugget to work with than Paul or I had. How's that for feeding your ego? Maybe I should stop encouraging you
  13. That's what I would have done, too, but it doesn't work. You can replace the % with something else, make the macro do all it needs to, then change the "substitute" character(s) back to %s. This all works. But if you try to trim the variable containing the wayward %s, or if you try to save it to the clipboard, the macro fails. It causes a "Variable Not Set or Incorrect Variable Type" error.
  14. Honestly, no. My company purchased about 10 licenses to be used exclusively in my department almost 2 years ago. I was tasked with building macros to distribute to the rest of my team. I was limited by a number of factors, however: I was given absolutely no on-the-clock time to build macros. Forcing me to sacrifice personal time to build them (what I really ended up doing, was building the macros for myself while I should have been working, then utilizing those macros to play catch-up so my productivity didn't suffer - and then I tweaked them (read: dumbed them down) for distribution. All macros I built had to be submitted to the guy who actually researched automation tools, but who had little-to-no experience actually building macros. All macros submitted to him had to be approved by senior management for the department. All macros had to be password protected to prevent fiddling (read: tweaking/improving) by other members of my team (I couldn't change their minds about that), despite the fact that no two computers in the department are even close to the same (the closest we get is that most PCs are HPs, and all are running XP Pro, but the rest of the specs vary widely) Most of the people I work with range from technilogically challenged to technophobe, with one or two others whow are either "too good for automation" or so set in their ways, that learning to run a macro is just too much work... or something. So, thanks to the first 2 or 3 items above, distribution was a nightmare. Training on using them was a bear. And actually following-up with people to see if they were using them, and if they had any suggestions or problems was non-existent. Though I love the potential MEP has, as buggy and inconsistent as it is on my machine (I used to have the worst machine in the department, so any macro that worked on my machine would work on everybody's... my new machine is in the top 2-3, performance-wise, so if they don't run on mine, they won't run on anybody's), there is no chance I'll be able to ever convince management to upgrade our licenses. At least not in the near future.
  15. Nope, not using a laptop. I have semi-bad joints, so a lot of repetitive motion gets to me quickly. The back-and-forth of going to and from the mouse all day long bothers my shoulder and my elbow in a hurry. I've also found that, for the most part, anything that can be done from the keyboard is considerably more efficient. I know people who use the mouse to highlight and r-click for copy and paste. I learned how to use Shift and Ctrl+Shift with Arrow keys for highlight so many years ago I can't recall, and I knew Ctrl+C and Ctrl+V for copy/paste before I knew you could use r-click for those functions. So, if it can be done on the keyboard, I do it on the keyboard. If not, I build a macro that will do it through the keyboard. If even that's too cumbersome, then I still use the mouse. When posting to the forum, I navigate with the mouse. Again, it's the repetitive motion of back and forth that is problematical. If my hand is already on the mouse, then it's not a problem. So for functions that leave my hand on the mouse for a few minutes, or for numerous consecutive functions, it isn't a problem. Clicking through websites, for example, is not usually a problem. It's when my job-function (or anything else, really) calls for: Type a word or two, mouse-move and click, Type a word or two, mouse-move and click, etc... that I get annoyed. When using the Variables button within an MEP function (like what we were discussing in this thread), I will usually tab to that button, and Enter to open it, but then the menus themselves can't be opened by any combination of keystrokes (to my knowledge), requiring me to use the mouse. And since the menus are not very efficiently built in the first-place, I hate that method... though I do use it when I really need to.
  16. True, and I use it (occasionally)... but it's mouse-intensive and I hate using the mouse... ever. I'd rather type than use the mouse Also true. However I find I misspell more often when I'm worrying about typing % and [ and ]... I frankly hate the whole brackets concept with regard to variable arrays, but I accept them as a necessary evil. I just mis-type them very often. It's nice that the backspace key is located so close to the bracket keys.
  17. Hey Terry, I think I may have skipped this thread, as my solution would have been what Paul suggested (about replacing the % with something else), but now that I've tied this thread together in my mind with the other one, I came back. And now that I'm home I can actually see the embedded images you've provided. And what you're trying to do is something that I would like to be able to do as well, but have been too lazy to bother working on it. Until now, apparently. From what I can see, you're putting the Variable name in first, and want the macro to copy the variable, duplicate it, and strip the % from the first instance but not the second. I would personally suggest a different method. Since I hate typing % signs around my variables, I would recommend typing out only the variable name without % signs, and then run the following macro (sans text boxes), which will do exactly what you need it to do. It is a very close representation of the macro Cory built and I modified, but now modified further for this particular case: Text Box Display: Copy text Delay: .25 seconds Variable Set String %topwindow% to topmost window title Variable Set to ASCII Char 10 to %LF% Variable Set to ASCII Char 13 to %CR% Variable Set String %Clip% from the clipboard contents Variable Modify String %Clip%: Append Text (%CR%%LF%) Variable Set Integer %Position% to the position of "%CR%" in %Clip% Repeat Until %Position% Equals "0" Variable Modify Integer %Position%: Decrement Variable Modify String: Copy a substring in %Clip%, starting at 1 and %Position% characters long to %Chunk% Variable Modify Integer: %Position% = %Position% + 2 Variable Modify String %Clip%: Delete a substring starting at 1 and %Position% characters long Variable Set Integer %Position% to the position of "%CR%" in %Clip% Variable Modify String %Output%: Append Text (%Chunk% = %%Chunk%%%CR%%LF%) End Repeat Window Activate: %topwindow% Delay: .25 seconds Text Type (Use Clipboard and Paste Text): %Output% <TEXT BOX DISPLAY Title="Copy text" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Copy text to the clipboard, then click OK.\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="FALSE" Mode="\x00" Delay="0"/> <DELAY Flags="\x01" Time=".25"/> <VARIABLE SET STRING Option="\x05" Destination="%topwindow%"/> <VARIABLE SET TO ASCII CHAR Value="10" Destination="%LF%"/> <VARIABLE SET TO ASCII CHAR Value="13" Destination="%CR%"/> <VARIABLE SET STRING Option="\x02" Destination="%Clip%"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Clip%" Value="%CR%%LF%"/> <VARIABLE SET INTEGER Option="\x0E" Destination="%Position%" Text_Variable="%Clip%" Text="%CR%" Ignore_Case="FALSE"/> <REPEAT UNTIL Variable="%Position%" Condition="\x00" Value="0"/> <VARIABLE MODIFY INTEGER Option="\x08" Destination="%Position%"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Chunk%" Variable="%Clip%" Start="1" Count="%Position%"/> <VARIABLE MODIFY INTEGER Option="\x00" Destination="%Position%" Value1="%Position%" Value2="2"/> <VARIABLE MODIFY STRING Option="\x0A" Destination="%Clip%" Start="1" Count="%Position%"/> <VARIABLE SET INTEGER Option="\x0E" Destination="%Position%" Text_Variable="%Clip%" Text="%CR%" Ignore_Case="FALSE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Output%" Value="%Chunk% = %%Chunk%%%CR%%LF%"/> <END REPEAT/> <WINDOW ACTIVATE Title="%topwindow%" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/> <DELAY Flags="\x01" Time=".25"/> <TEXT TYPE Action="1" Text="%Output%"/> The problem I've been having is that it doesn't seem possible to Trim or Save to Clipboard if the contents of the %Output% variable contains undefined variables in quotes. Now the trick of switching % with something else is a fine idea, except that you have to switch it back before saving it to the clipboard, at which point the macro fails. So the solution I found and used above is simply to have the macro do a text type paste, requiring that you use some activate window commands. But all-in-all, it's fairly functional.
  18. I just tried this one, too, since it performs more exactly what Terry originally requested (creating files was offered by Paul and I, whereas Terry just wanted to modify a "live" notepad). I discovered a problem, however, that requires additional commands to rectify. This code assumes the text being copied ends with a line-break. If it does not, the macro will stop processing on the pen-ultimate line, and the last line will not be appended to the %Output% variable. The simple fix is to add this simple line just after setting the %Clip% variable from the clipboard contents. Variable Modify String %Clip%: Append Text (%CR%%LF%) This will ensure that the macro continues until all lines have been duplicated and placed in the Output variable. At this point you may want to add one or two more lines of code after the End Repeat command, depending on what you want. If the text copied did end with a CR/LF, then you'll end up with an extra one placed in your clipboard when the %Output% variable gets pushed. So you simply need to Trim the Output variable. This will get rid of all the ending line-breaks. At this point you might want to append one more %CR%%LF% to the Output variable (if you do want a final line-break).
  19. That's interesting because, like Terry, I have often been under the impression that activating a window was no guarantee that the window would be available. So I tend to follow my Activate commands with a Wait command as well. Interesting.
  20. That is actually exactly what I did. I did it for a few reasons. Mainly, I did it in order to learn the MEP fuctionality so that if the company ever did decide to splurge, I would be prepared for it. However, I also tend to be the only person who uses Macros for most of my work (everybody else seems to fear them), so I figured I would at least be able to benefit from the enhanced product. Of course the few macros that everybody else uses are tried and true and they don't have to live with the bugs that are still being tweaked out of MEP the way I do.
  21. I second Paul's solution. You've got a few options, too. You could simply define %Snapshot% before beginning the repeat loop; however, my preferred method would be this: Repeat Start (Repeat 99 times) // Store counter in %Snapshot% Get Pixel Color from Beneath the Mouse into %N[%Snapshot%]% Text Box Display: Delay: 100 milliseconds End Repeat Text Box Display: <REPEAT START Start="1" Step="1" Count="99" Save="TRUE" Variable="%Snapshot%"/> <GET PIXEL COLOR Option="\x00" Rel_To_Screen="TRUE" Destination="%N[%Snapshot%]%"/> <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Snapshot = \\f1 %Snapshot%\r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <DELAY Flags="\x02" Time="100"/> <END REPEAT/> <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %N[1]%\r\n\\par %N[\\f1 2\\f0 ]%\r\n\\par %N[\\f1 3\\f0 ]%\r\n\\par %N[\\f1 4\\f0 ]%\r\n\\par %N[\\f1 5\\f0 ]%\r\n\\par %N[\\f1 6\\f0 ]%\r\n\\par %N[\\f1 7\\f0 ]%\r\n\\par %N[\\f1 8\\f0 ]%\r\n\\par %N[\\f1 9\\f0 ]%\r\n\\par %N[\\f1 10\\f0 ]%\r\n\\par %N[1\\f1 1\\f0 ]%\r\n\\par %N[1\\f1 2\\f0 ]%\r\n\\par %N[1\\f1 3\\f0 ]%\r\n\\par %N[1\\f1 4\\f0 ]%\r\n\\par %N[1\\f1 5\\f0 ]%\r\n\\par %N[1\\f1 6\\f0 ]%\r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> By using Repeat Start rather than Repeat Until, you still get to specify 99 iterations. But since you're storing the counter in %Snapshot%, you never have to define Snapshot = 1 and you never have to use the Modify Variable Increment command on Snapshot, as the Counter will increment it automatically. So you eliminate two steps by combining them all within the Repeat Start command. That's my suggestion.
  22. Yep, definitely better. I went with ASCII because I use it a lot, but Text File process is definitely better for a simple text file like this, i.e. no tabs to delimit. The primary difference is that there aren't any arrays to handle, so rather than worrying about %LineProcess[x]%, you just have %LineProcess%. Definitely prettier. I adjusted my macro to reflect Kevin's observation, and it tests true. <TEXT FILE BEGIN PROCESS Filename="C:\\Documents and Settings\\z051940\\Desktop\\Lines.txt" Start_Record="1" Process_All="TRUE" Records="1" Variable="%LineProcess%"/> <VARIABLE SET STRING Option="\x00" Destination="%ModifiedProcess%" Value="%LineProcess% %LineProcess%"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%ModifiedProcess%" Filename="C:\\Documents and Settings\\z051940\\Desktop\\Lines2.txt" CRLF="TRUE"/> <TEXT FILE END PROCESS/> <COPY FILE/FILES Source="C:\\Documents and Settings\\z051940\\Desktop\\Lines2.txt" Dest="C:\\Documents and Settings\\z051940\\Desktop\\Lines.txt" Progress="FALSE" Recurse="FALSE"/> <DELETE FILE/FILES Path="C:\\Documents and Settings\\z051940\\Desktop\\Lines2.txt" Progress="FALSE" Recurse="FALSE" Permanent="FALSE"/>
  23. Ok, I guess I did what Paul suggested... except I had assumed the file was already saved. So in order for mine to work, you'd have to do what Paul suggested. Sorry Paul. Didn't mean to steal your thunder !
  24. I built this macro for you, Terry. Tested it with 100% success. I took your test text and saved it into a .txt file on my desktop. The file name: Lines.txt I set each line of the process to variable %LineProcess[x]%. (Note that for this particular macro x will always be 1 - there are not Tabs to delimit) I then set variable %ModifiedProcess% as: %LineProcess[1]% %LineProcess[1]% At this point, I append the variable %ModifiedProcess% to a new text file (Line2.txt) with trailing CR/LF checked. The process repeats until all lines have been processed. I now copy file Lines2.txt to file Lines.txt (this effectively over-writes the original Lines.txt). For my coup de grĂ¢ce I delete Lines2.txt leaving my desktop as it was before I ran the macro. But with a new and improved Lines.txt Here's the code: ASCII File Begin Process: "C:\Documents and Settings\z051940\Desktop\Lines.txt" (Tab Delimited Text (.txt)) Variable Set String %ModifiedProcess% to "%LineProcess[1]% %LineProcess[1]%" Variable Modify String: Append %ModifiedProcess% to text file, "C:\Documents and Settings\z051940\Desktop\Lines2.txt" ASCII File End Process Copy File/Files: "C:\Documents and Settings\z051940\Desktop\Lines2.txt" to "C:\Documents and Settings\z051940\Desktop\Lines.txt" Delete File/Files: "C:\Documents and Settings\z051940\Desktop\Lines2.txt" <ASCII FILE BEGIN PROCESS Filename="C:\\Documents and Settings\\z051940\\Desktop\\Lines.txt" Format="Tab" Start_Record="1" Process_All="TRUE" Records="1" Variable="%LineProcess%" Start_Index="1"/> <VARIABLE SET STRING Option="\x00" Destination="%ModifiedProcess%" Value="%LineProcess[1]% %LineProcess[1]%"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%ModifiedProcess%" Filename="C:\\Documents and Settings\\z051940\\Desktop\\Lines2.txt" CRLF="TRUE"/> <ASCII FILE END PROCESS/> <COPY FILE/FILES Source="C:\\Documents and Settings\\z051940\\Desktop\\Lines2.txt" Dest="C:\\Documents and Settings\\z051940\\Desktop\\Lines.txt" Progress="FALSE" Recurse="FALSE"/> <DELETE FILE/FILES Path="C:\\Documents and Settings\\z051940\\Desktop\\Lines2.txt" Progress="FALSE" Recurse="FALSE" Permanent="FALSE"/>
  25. I have about 10 different apps, utilites, inter- and intranet sites that all need to be opened and logged into; windows that need to be resized and repositioned, etc. So I have a "Start" short-key that starts the monotonous process. While it's running I can eat my breakfast, go through hard-copy files, run to the restroom, get a drink, whatever I need to do.
×
×
  • Create New...