Jump to content
Macro Express Forums

terrypin

Members
  • Posts

    2,230
  • Joined

  • Last visited

  • Days Won

    23

Everything posted by terrypin

  1. Here's my version, which works OK here. It's heavily commented so hopefully easy to follow, but post if anything unclear. // These variables will be used to end each line of the edited file Variable Set to ASCII Char 13 to %CR% // Set CR Variable Set to ASCII Char 10 to %LF% // Set LF Variable Set String %CRLF% to "%CR%%LF%" // Set combined CRLF // Split each the line into as many parts as the max expected (up to 99). I've used 10. Text File Begin Process: C:\Users\terry\Dropbox\Macro Express (Sundry)\Parsing-1.txt // Test if line is blank. If Variable %tLine% Equals "" // Include a blank line and bypass the split. Variable Set String %tArray[1]% to "" Goto:AfterSplit End If // If there is no comma in the line AND it is not blank, ignore it and go to the next. If Variable %tLine% Does not Contain "," AND If Variable %tLine% Does not Equal "" Continue End If // Otherwise proced to parse. Split String "%tLine%" on "," into %tArray%, starting at 1 // But only use the first element, tArray[1]. Ignore the rest. // Build the result, stating with an empty new file. // Add a new line. :AfterSplit Variable Modify String %tEditedFile%: Append Text String Variable (%tArray[1]%) // Add the EOL characters Variable Modify String %tEditedFile%: Append Text String Variable (%CRLF%) Text File End Process Variable Modify String: Save %tEditedFile% to "C:\Users\terry\Dropbox\Macro Express (Sundry)\EditedFile.txt" Beep: Save %tEditedFile% to "C:\Users\terry\Dropbox\Macro Express (Sundry)\EditedFile.txt" // End of macro, so edited file sholud be ready. Full code: <COMMENT Value="These variables will be used to end each line of the edited file"/> <VARIABLE SET TO ASCII CHAR Value="13" Destination="%CR%" _COMMENT="Set CR"/> <VARIABLE SET TO ASCII CHAR Value="10" Destination="%LF%" _COMMENT="Set LF"/> <VARIABLE SET STRING Option="\x00" Destination="%CRLF%" Value="%CR%%LF%" NoEmbeddedVars="FALSE" _COMMENT="Set combined CRLF"/> <COMMENT Value="Split each the line into as many parts as the max expected (up to 99). I've used 10."/> <TEXT FILE BEGIN PROCESS Filename="C:\\Users\\terry\\Dropbox\\Macro Express (Sundry)\\Parsing-1.txt" Start_Record="1" Process_All="TRUE" Records="1" Variable="%tLine%"/> <COMMENT Value="Test if line is blank.\r\n"/> <IF VARIABLE Variable="%tLine%" Condition="\x00" IgnoreCase="FALSE"/> <COMMENT Value="Include a blank line and bypass the split."/> <VARIABLE SET STRING Option="\x00" Destination="%tArray[1]%" NoEmbeddedVars="FALSE"/> <GOTO Name="AfterSplit"/> <END IF/> <COMMENT Value="If there is no comma in the line AND it is not blank, ignore it and go to the next.\r\n"/> <IF VARIABLE Variable="%tLine%" Condition="\x07" Value="," IgnoreCase="FALSE"/> <AND/> <IF VARIABLE Variable="%tLine%" Condition="\x01" IgnoreCase="FALSE"/> <CONTINUE/> <END IF/> <COMMENT Value="Otherwise proced to parse."/> <SPLIT STRING Source="%tLine%" SplitChar="," Dest="%tArray%" Index="1"/> <COMMENT Value="But only use the first element, tArray[1]. Ignore the rest."/> <COMMENT Value="Build the result, stating with an empty new file."/> <COMMENT Value="Add a new line."/> <LABEL Name="AfterSplit"/> <VARIABLE MODIFY STRING Option="\x07" Destination="%tEditedFile%" Variable="%tArray[1]%" NoEmbeddedVars="FALSE"/> <COMMENT Value="Add the EOL characters"/> <VARIABLE MODIFY STRING Option="\x07" Destination="%tEditedFile%" Variable="%CRLF%" NoEmbeddedVars="FALSE"/> <TEXT FILE END PROCESS/> <VARIABLE MODIFY STRING Option="\x11" Destination="%tEditedFile%" Filename="C:\\Users\\terry\\Dropbox\\Macro Express (Sundry)\\EditedFile.txt" Strip="FALSE" NoEmbeddedVars="FALSE"/> <BEEP _COMMENT="End of macro, so edited file sholud be ready."/>
  2. What sound do others hear when using the Beep command? Here, with Win 10, it gives the same as C:\windows\media\Windows Background.wav rather than the traditional, simple monotone (matching the name 'beep') that I recall in the past.
  3. Thanks both, appreciate the feedback. I’ll report it as a possible bug.
  4. I'm making more use of the handy Set Background color... option, and sometimes need lighter colours than those in the main grid of the Colour dialog. But after using Define Custom Colours to add my own, and returning to work on the macro later, these have disappeared. What is the expected lifetime of Custom Colours and what behaviour do other users see please?
  5. Hi Tim, Did you try making the very first command a Delay? Say: Delay: 0.1 seconds P.S. I think you're forgetting to crop your screenshots. Terry
  6. I'm constantly fidgeting with my mouse and would soon be staring at a blank screen 😉
  7. I’m unable to clearly visualise what you are seeing but I’d definitely agree with @rberq’s suggestion to abandon that approach. The text file method is probably the best. But one alternative you might consider is to place a Variable Set String with a Prompt at the start. Use that variable to type the text. On my iPad at the moment so haven’t tested it. EDIT: Back on my PC I tested that idea and it works as expected. Here's an example macro. It uses two variable commands to make changing the text easy. Variable Set String %tText% to "I'd suggest you first reduce the problem to its absolute essentials. If I have it right, there is one particular set of video files that, when imported into version X of MEP, don't behave correctly. Therefore can you upload a small (non-confidential) example so that we can try it. I'm hopeful that we might find a suitable conversion of the troublesome files. You also need to give us more information so that we have a better chance to help. Start with the version of MEP that you're using! But then read this sticky too: " Variable Set String %tText%: Prompt Text Box Display: %tText% Terry
  8. That's intriguing! But I don't seem able to reproduce it. I'm running from debug mode (F9) if that matters. Choose the browser title and hit Enter. Then quickly click anywhere else. Not only does the macro not immediately complete, but it doesn't complete at all and has to be terminated.
  9. Arising out of the current posts by@sdspieg I see that on my Win 10 Pro PC (i7, 4.0 GHz) pixel-hunting macros are now even slower than I last recall. What performance do others get please? For example, try the following macro (modified to suit). Here it takes about 15 seconds to get from y=0 to 842, that's less than 60 pixels/sec! COMMANDS Variable Set Integer %nMouseY% to 0 Repeat Until %nPixCol% Equals "12870323" Get Pixel Color at (187, %nMouseY%) Relative to Current Window into %nPixCol% Variable Modify Integer %nMouseY%: Increment End Repeat Text Box Display: Result CODE <VARIABLE SET INTEGER Option="\x00" Destination="%nMouseY%" Value="0"/> <REPEAT UNTIL Variable="%nPixCol%" Condition="\x00" Value="12870323"/> <GET PIXEL COLOR Option="\x01" Rel_To_Screen="FALSE" X="187" Y="%nMouseY%" Destination="%nPixCol%"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%nMouseY%"/> <END REPEAT/> <TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 \r\n\\par The colour required has been found at the location specified.\r\n\\par nMouseY = %nMouseY%\r\n\\par \\f1 \r\n\\par }\r\n" Left="676" Top="Center" Width="423" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> BTW, @sdspieg, the macro above avoids that unnecessary extra variable you used. I get the the same speed if I move the mouse cursor itself. Of course, in many situations the target may be a large enough solid colour to significantly improve the speed by using a larger increment than 1. But take care that it really is a uniform exact colour. Despite appearances, the example here is not. (That's on the original MX Forum screen; the purple circle in my JPG will contain many more variations.) And in a real life macro i would naturally start with y = a value much closer to my target. Obscuring the issue: I use a macro of this type that does occasionally run much faster. Pointing perhaps to some sort of frequent but not permanent timing conflict? Win 10 only? My PC only? Terry
  10. Hi, Take care when defining the target position's pixel colour. Sometimes it changes by the very act of placing the mouse cursor over it. Possibly why your macro did not work. Instead of the built in Mouse Locator, use a simple macro that does not require the mouse, with the command Get Pixel Color at (%x%, %y%) Relative to Screen into %PixCol% Terry
  11. Can you post your macro, showing both the script commands and the direct code, so that we can see how far you’ve got. Include Comments wherever a command is not obvious. What is the work environment? Is this all to be done within the macro, or while typing in a text editor or word processor application. Have you experimented by running the macro from @acantor? And extended it by setting %Input% from the clipboard or a Prompt command? Or, if you haven't got anywhere at all yet, work with this simple macro before tackling what sounds a rather challenging one for a beginner. COMMANDS: // Start by understanding the basic stuff. // This simple macro searches for instances of a specified string within text that has first been copied to the Windows clipboard. // Assumes you are searching for the string 15.01.1987 Variable Set String %tInput% from the clipboard contents Variable Modify String: Replace "15.01.1987" in %tInput% with ""15.01.1987"" Text Box Display: Result DIRECT CODE <COMMENT Value="Start by understanding the basic stuff."/> <COMMENT Value="This simple macro searches for instances of a specified string within text that has first been copied to the Windows clipboard."/> <COMMENT Value="Assumes you are searching for the string 15.01.1987"/> <COMMENT/> <VARIABLE SET STRING Option="\x02" Destination="%tInput%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%tInput%" ToReplace="15.01.1987" ReplaceWith="\"15.01.1987\"" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %tInput%\r\n\\par }\r\n" Left="123" Top="485" Width="1114" Height="649" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> Run it either by the method I described earlier, or from the exported macro attached. EnclosingSpecifiedTextInQuotes.mex
  12. OK, looks like we crossed in the post, while I was editing mine after seeing your second post! Much simpler indeed. 😉 Unless you hear back from @cantor beforehand, I'll reply again after breakfast. Terry, UK Sunday 27 December 2020, 0914
  13. Hi, With time zones in mind, before @acantor replies perhaps you could clarify your requirement. Is it really simply to add quotation marks before and after a target string, as your last post implies? Or is it the much more complex requirement to add " and "? If the latter, which is how I first interpreted it could you give three 'before and after' examples of text to which you will apply your macro: 1. Containing the target string, say 'xyz' or 'abc xyz' or whatever. 2. As #1 but also containing one or more instances of 'and' or 'And' inside the target string, say 'abc and xyz'. 3. As #2 but containing one or more instances of 'and' or 'And' inside and outside the target string. -------------------- To test the macro, copy the second section (the Code section starting "<VARIABLE SET STRING Option=") and paste it into a new empty macro. Or show us your code so that we can be more specific. For instance, @cantor's macro assumes a variable %Input%, so you will need to integrate that into your own code. Terry, UK Sunday 27 December 2020, 0851
  14. Thanks Alan. I’ll contact Support about it, as it really would be helpful to get it alphabetised. Just as it is in the Explorer window. That’s my usual first visit before choosing a new hot key, to ensure no global macros will conflict. Have you not encountered difficulties with Alt+ hotkeys, due to Alt often opening a program’s menu? Terry
  15. What order are hotkey candidates meant to be? Was it not once in strict alphabetic sequence? IOW, all hotkeys Alt+ before Ctrl+, etc? At present it's hard to see any logic to the sequence, which makes selecting one difficult, especially if you have many hundreds already assigned.
  16. Can you show us your latest code, with comments if each step is not obvious, matching the explanation you gave. Have you successfully written simpler macros before this? It does sound as if you need to study the basic stuff and work through simple examples. Did you try running the demo I wrote for you a week ago? Do you understand what it is doing? I don’t know Zenfolio, and I suspect none of us regulars here do, so as I said it’s best to work with a more accessible application, like Notepad. Meanwhile I assume you’re implying that the obvious step of using the Enter or Arrow Down command to navigate to the next entry does not work?
  17. Kind of you to say so, Alan. But I note that neither of us has had a ‘thank you’ from the OP.
  18. Thanks @Samrae, you've solved the puzzle. I use a 15 or 20 year old hotkey macro to place the full path and filename of any selected File Explorer file onto the clipboard. That turns out to be the cause of the inconsistency. It had a few lines built in to handle files in the root which otherwise misbehaved: If Variable %tFolder% Equals "C:\" Variable Modify String: Replace "\" in %tFolder% with "" End If But C was the only root for which I'd eliminated the double '\\' . Looks like I've never before used the macro on any other, or if I did it never caused trouble!
  19. Meanwhile here's a macro using the more accessible Notepad. Study that and try adapting it to your requirement. Come back if you need further help // Demo for @Jimbojones // Set a variables for TAB Variable Set to ASCII Char 9 to %TAB% // Set TAB // Presumably you want to place the text cursor in a box on some already open web site. // In my version I'll activate 'Untitled - Notepad' (already open). // The macro will use the following CSV file, containing 5 records, each with two fields: Record #1, Jim Record #2, John Record #3, Jack Record #4, Jill Record #5, Janet Window Activate: Untitled - Notepad Wait for Window Title: Untitled - Notepad // For each RECORD in the FILE, type the first FIELD into Notepad. ASCII File Begin Process: "C:\Users\jimrm\Desktop\Names.csv" (Comma Delimited Text (.csv)) Text Type (Simulate Keystrokes): %T[1]% Delay: 0.1 seconds // As a crude simulation of navigating to another location on the same web page, TAB before entering the remaining field. Text Type (Simulate Keystrokes): %TAB% Delay: 0.1 seconds // For each RECORD, type the second FIELD into the same line Text Type (Simulate Keystrokes): %T[2]%<ENTER> Delay: 0.1 seconds ASCII File End Process Delay: 0.1 seconds <COMMENT Value="Demo for @Jimbojones"/> <COMMENT Value="Set a variables for TAB"/> <VARIABLE SET TO ASCII CHAR Value="9" Destination="%TAB%" _COMMENT="Set TAB"/> <COMMENT Value="Presumably you want to place the text cursor in a box on some already open web site."/> <COMMENT Value="In my version I'll activate 'Untitled - Notepad' (already open)."/> <COMMENT Value="The macro will use the following CSV file, containing 5 records, each with two fields:\r\nRecord #1, Jim\r\nRecord #2, John\r\nRecord #3, Jack\r\nRecord #4, Jill\r\nRecord #5, Janet"/> <WINDOW ACTIVATE Title="Untitled - Notepad" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/> <WAIT FOR WINDOW TITLE Title="Untitled - Notepad" Partial="TRUE" Wildcards="FALSE" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/> <COMMENT Value="For each RECORD in the FILE, type the first FIELD into Notepad."/> <ASCII FILE BEGIN PROCESS Filename="C:\\Users\\jimrm\\Desktop\\Names.csv" Format="CSV" Start_Record="1" Process_All="TRUE" Records="1" Variable="%T%" Start_Index="1" Parse_Blank_Lines="FALSE" Clear_Array="TRUE"/> <TEXT TYPE Action="0" Text="%T[1]%"/> <DELAY Flags="\x01" Time="0.1"/> <COMMENT Value="As a crude simulation of navigating to another location on the same web page, TAB before entering the remaining field."/> <TEXT TYPE Action="0" Text="%TAB%"/> <DELAY Flags="\x01" Time="0.1"/> <COMMENT Value="For each RECORD, type the second FIELD into the same line"/> <TEXT TYPE Action="0" Text="%T[2]%<ENTER>"/> <DELAY Flags="\x01" Time="0.1"/> <ASCII FILE END PROCESS/> <DELAY Flags="\x01" Time="0.1"/> NOTE typo: The Comment directly before the ASCII File Begin Process command should of course be the first command within it. (Apparently it's hard to edit code boxes here!) SORTB NAMES-MyVersion.mex
  20. Hi Jim, It would be easier to help if we had your CSV file and the URL (or simplifed non-confidential examples) , and also a much fuller explanation of the task. Are you copying each record of your CSV file into an identical location of successive different web pages? If so, where are the commands that open subsequent pages? Or, are there just two records in the CSV file, copied to two text fields of the web page? Or two fields in each record? It also looks like you're using integer variable %C% but I don't see where it gets incremented? And is your macro deliberately simplified to a mere two repetitions of the main loop? I don't follow your logic. Could you spell out in full the sequence of events you want to emulate please? Amongst other things perhaps you're not adding an empty line between the two records, so overwriting the first. (Although you say it's the second you're seeing?) Are you trying to use the variable T as an array? If so you have not defined it as such. I'd recommend you tidy up your draft recorded macro by replacing those arbitrary delays, say with Delay: 0.1 seconds A simple left click is usually OK after a mouse move. And did you first try navigating to the location(s) with Tabs, a preferable method; pixel locations will differ for each of us if we ever try to run your macro on the specified page. You're also apparently selecting two different targets on the page but only the second becomes one? I assume the vertical resolution of your screen must be larger than my 1200 for that to be a valid location? Note that unless your browser is always maximised (or has a consistent size and position) it's safer to set Mouse Move commands relative to the window, not screen. Terry
  21. I needed to get a macro I wrote yesterday on my ancient shed workshop PC to this Win 10 PC in my house office. I exported it to a USB stick where it was called M:\\AttributeChangeDateFromShed.mex Surprisingly it failed, giving the message "The filename is not valid." After some experiment I discovered that it works OK if I placed the file instead in M:\From Shed\AttributeChangeDateFromShed.mex So looks like it only fails if placed at the root level.
  22. You might get more specific help if you tell us the site link and show us the table, plus the macro you have attempted so far. Meanwhile, following Cory’s suggestion, if you have now managed to select the entire table (of text?) and copy it to the clipboard, I’d suggest next using Variable Set String > Set Value from Clipboard
  23. Thanks Alan, appreciate your offer, although as I don’t use Outlook I’ll pass. If/when I get more time on MX Pro I’ll try a few examples myself, using your suggested approach.
  24. Hi Alan, Interesting post, thanks. I’ve used Controls very little, never having developed much confidence in their consistency. Are you saying that making Title identical to Caption improves or even fully resolves that issue? It naturally raises the question of potential adverse effects, as presumably the two fields are intentionally distinct? I suspect I haven’t fully understood your recommendation. Perhaps you could give an example or two? Terry
×
×
  • Create New...