Jump to content
Macro Express Forums

rberq

Members
  • Content Count

    865
  • Joined

  • Last visited

  • Days Won

    40

rberq last won the day on June 29

rberq had the most liked content!

Community Reputation

27 Excellent

About rberq

  • Rank
    Master

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Ctrl-1/2/3 etc. seem to work in Firefox and in IE also. If there are more than eight tabs in Firefox, Ctrl-9 takes you to the last one. Things I never knew before ....🙃
  2. Look up keyboard shortcuts for Chrome. When I Googled "keyboard shortcut to switch to a specific Chrome tab", I found that Ctrl-1 activates the first tab, Ctrl-2 activates the second, and so on. So if your Parts tab is always the second one, instead of doing "Window Activate", use the Text Type command to "type" Ctrl-2. Of course Chrome itself will have to be in focus to accept the keystrokes. I don't know for sure that this will work for you, but it's worth a try.
  3. Simpler than mine. Hardest part of making the macro is looking up the Excel keyboard shortcuts.
  4. Now that's impressive!!! You did OCR strictly with ME macros??? How much data did you have to get off a typical document -- a few key characters, or whole lines, or pages of text? How large were the fonts, or did you blow up the PDFs to make gigantic letters? Even though you were working with known fonts and sizes, there must have been slight variations between the pixels "read" and the standardized pixel maps. How did you adjust for the differences? How did you determine that a character was, or was not, a match to one of the maps? By sampling a few dozen, or a few hundred, pixels within a known space on the screen? When you say you could read "very quickly", what does that mean in characters per second, or however you measured it? Sounds like wicked good programming fun!!!
  5. Yes and no. Lots of nice features in ME that make it easy to do stuff beyond keyboard and mouse functions. For simple jobs it's quick and easy, but then one can get sucked in to using it beyond where its strengths are. As a high-level language, the fact that you have to define your own inter-module structure means my techniques will probably differ a lot from yours. Like the days when every bicycle mechanic became his own automobile manufacturer -- eventually Henry Ford had a better idea. ME works nicely as one tool in the box but doesn't replace the whole box.
  6. This seems to work well with Excel 2010. Before initiating the macro, hover the mouse over any cell in the row to be moved down. Then keyboard shortcuts are used. Though row X is to be moved down, the macro actually creates an empty row above X, then copies the row below X to the clipboard and pastes it into the empty row, then deletes the copied/pasted row. The last step of the macro is to position the mouse over the row that has just been moved down, so that no manual repositioning is needed to move it down further – just initiate the macro again. A macro to move a row up would be similar. // // // move excel row down -- mouse hovered over row to be moved // select any cell in row to be moved, based on mouse hovering over it Mouse Left Click // keyboard select entire row to be moved Text Type (Simulate Keystrokes): <SHIFTD><SPACE><SHIFTU> // keyboard insert empty row above row to be moved Text Type (Simulate Keystrokes): <CTRLD><SHIFTD>=<SHIFTU><CTRLU> // keyboard arrow down to row below that to be moved down, keyboard select entire row, copy to clipboard Text Type (Simulate Keystrokes): <ARROW DOWN><ARROW DOWN><SHIFTD><SPACE><SHIFTU><CTRLD>c<CTRLU> // keyboard arrow up to the blank inserted row, keyboard select entire row, paste copied row from clipboard Text Type (Simulate Keystrokes): <ARROW UP><ARROW UP><SHIFTD><SPACE><SHIFTU><CTRLD>v<CTRLU> // keyboard arrow down to row below that to be moved down, keyboard select entire row, keyboard delete row Text Type (Simulate Keystrokes): <ARROW DOWN><ARROW DOWN><SHIFTD><SPACE><SHIFTU><CTRLD>-<CTRLU> // Keyboard arrow up to the row just moved, position mouse over row so we can repeat macro to move it down still more Text Type (Simulate Keystrokes): <ARROW UP> Mouse Move: To the Text Cursor Position // Macro Return // //
  7. Also check Options | Preferences | Playback | Delay After Keystroke Down (and UP). On my system, both items are check-marked, and the suggested 300 microseconds is specified. Are these macros that previously worked, and are now failing? Or have they never worked reliably? Is your PC fairly modern? What version of Windows?
  8. The icons along the right side are so subdued that I didn't even notice them (bear in mind I only started using ME Pro a couple weeks ago.)🙄 But I have for a long time used the keyboard equivalents ctrl-up-arrow, ctrl-down-arrow, and ctrl-d to move or duplicate highlighted lines. I haven't figured out the keyboard shortcut for adding a comment, but while experimenting I discovered that ctrl-x deletes highlighted line(s).
  9. Odd. It DOES work for me in Word. Also works in Notepad.
  10. I have been astonished how well my Android phone understands my speech. Not only Google searches, but the map application, too. Instead of all that typing with fingers or a stylus, I can just say, "Hey, Google, navigate to Kalamazoo," and it comprehends.
  11. Yeah, but then my wife will know what I am up to, and offer her opinions.🙄 But that's a great idea. I like my smartphone feature, where I can just say, "Hey, Google, what's the population of Paraguay, and where the heck is Paraguay, anyhow?" and it tells me. I will look into Dragon. Maybe I can just mumble and it will understand....
  12. I have used the opposite approach in many macros, to establish the text cursor position. Generally this is by positioning the mouse over an item, such as one of the titles in a list of emails, or a file name in Explorer, or a word within text. Then hit the hotkey combination to start a macro, and the first thing the macro does is click the mouse to establish the cursor position. Biggest problem with this is, when I move my hands to the keyboard to start the macro, the touch-pad detects the movement and slides the mouse pointer to somewhere else! Perhaps the next ME release will have a brain-wave interface so I can just think "run macro now" without moving my hands. But I will have to keep in mind the possibilities for this command. I experimented a bit this morning and it worked in most of the applications I tested with.
  13. Works well now with the more-common Notepad method of (1) using the ENTER key to start a new line, or just typing along and letting Notepad wrap the words; and (2) using two ENTERs in a row to start a new paragraph by double-spacing. This involved simply scanning the text for two contiguous CRLFs, and if any is/are found, then all single CRLFs are removed. Haven't really tested extensively with lots of documents -- it's fun but I don't envision much use for this macro. <COMMENT Value=" "/> <LOG MESSAGES Filename="C:\\Temp\\MacroExpressProLogFiles\\MacroExpressPro_Macro_Log_File.txt" Message="Macro name: Kbyd_Paragraph" Stamp="TRUE"/> <LOG ERRORS Hide_Errors="FALSE"/> <COMMENT Value="Line Feed (New Line) character ascii 10"/> <VARIABLE SET TO ASCII CHAR Value="10" Destination="%LF%"/> <COMMENT Value="Carriage Return character ascii 13"/> <VARIABLE SET TO ASCII CHAR Value="13" Destination="%CR%"/> <COMMENT Value="Carriage Return / Line Feed combination characters ascii 13 + ascii 10"/> <VARIABLE MODIFY STRING Option="\x08" Destination="%CRLF%" Variable="%CR%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x07" Destination="%CRLF%" Variable="%LF%" NoEmbeddedVars="FALSE"/> <COMMENT Value="Octal 01 and 02 "/> <VARIABLE SET TO ASCII CHAR Value="1" Destination="%Octal01%"/> <VARIABLE SET TO ASCII CHAR Value="94" Destination="%Octal01%" _ENABLED="FALSE" _COMMENT="caret ^"/> <VARIABLE SET TO ASCII CHAR Value="2" Destination="%Octal02%"/> <VARIABLE SET TO ASCII CHAR Value="126" Destination="%Octal02%" _ENABLED="FALSE" _COMMENT="tilde ~"/> <COMMENT Value="Pattern to flag paragraph (insertion point) "/> <VARIABLE SET STRING Option="\x00" Destination="%pattern%" Value=")(*()(*()(*()(*()(*()][\\][p" NoEmbeddedVars="FALSE"/> <COMMENT Value="Maximum number of paragraphs to be handled by macro"/> <COMMENT Value="Clear %paragraph% array to hold up to 50 paragraphs "/> <VARIABLE SET INTEGER Option="\x00" Destination="%max_paragraphs%" Value="500"/> <CLEAR VARIABLES Type="Text Variables" Option="\x01" Variable="%paragraph%" Start="1" End="%max_paragraphs%" _COMMENT="clear storage array to hold paragraphs"/> <COMMENT Value=" "/> <COMMENT Value="Style_1 has one CRLF per paragraph.\r\nStyle_2 has a double-CRLF per paragraph, to double-space between paragraphs.\r\nStyle_2 may or may not have a CRLF for each line within a paragraph."/> <COMMENT Value=" "/> <COMMENT Value=" "/> <COMMENT Value="Text file should be already open in Notepad, with mouse hovering over paragraph which is to be moved down.\r\nInsert funny pattern of characters at insertion point."/> <MOUSE LEFT CLICK/> <TEXT TYPE Action="0" Text="%pattern%"/> <COMMENT Value=" "/> <COMMENT Value="Get Notepad content into veriable %book%. "/> <MACRO RUN Use_ID="FALSE" Name="0_Kybd_Copy_All" ID="-1" Wait="TRUE"/> <VARIABLE SET STRING Option="\x02" Destination="%book%" NoEmbeddedVars="FALSE"/> <DELAY Flags="\x11" Time="2" _ENABLED="FALSE"/> <TEXT BOX DISPLAY Title="Debugging -- display book content with pattern inserted" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %book%\\f1 \r\n\\par }\r\n" Left="25" Top="114" Width="1289" Height="566" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Make sure no octal 01 or 02 already exist in the text"/> <IF VARIABLE Variable="%book%" Condition="\x06" Value="%Octal01%" IgnoreCase="FALSE"/> <OR/> <IF VARIABLE Variable="%book%" Condition="\x06" Value="%Octal02%" IgnoreCase="FALSE"/> <TEXT BOX DISPLAY Title="Error" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Error: ZIP macro -- text to be compressed already contains the ESC Escape character, or an octal 01 or 02. These characters are not allowed, because they are used for special purposes within this macro.\r\n\\par \r\n\\par Macro aborted. \\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <MACRO RETURN/> <END IF/> <COMMENT Value=" "/> <COMMENT Value="Right-trim the overall text and add another copy of the marker pattern to the end,\r\npreceded by octal 02 so it will be split out as a (dummy) concluding paragraph. "/> <VARIABLE MODIFY STRING Option="\x02" Destination="%book%"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%book%" Value="%Octal02%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%book%" Value="%pattern%" NoEmbeddedVars="FALSE"/> <VARIABLE SET INTEGER Option="\x0D" Destination="%length_book%" Text_Variable="%book%"/> <COMMENT Value=" "/> <COMMENT Value="If text contains any double-CRLF, set Style_2 indicator. Otherwise Style_1. \r\nIf Style_2, replace double-CRLFs by octal 01, so we know where to put back the\r\ndouble-CRLFs later on. Then, if Style_2, get rid of single CRLFs (if any) that mark\r\nends of lines as opposed to paragraphs. "/> <IF VARIABLE Variable="%book%" Condition="\x06" Value="%CRLF%%CRLF%" IgnoreCase="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%style1%" Value="FALSE" NoEmbeddedVars="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%style2%" Value="TRUE" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book%" ToReplace="%CRLF%%CRLF%" ReplaceWith="%Octal01%" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book%" ToReplace="%CRLF%" ReplaceWith=" " All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book%" ToReplace="%Octal01%" ReplaceWith="%CRLF%" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <ELSE/> <VARIABLE SET STRING Option="\x00" Destination="%style1%" Value="TRUE" NoEmbeddedVars="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%style2%" Value="FALSE" NoEmbeddedVars="FALSE"/> <END IF/> <TEXT BOX DISPLAY Title="Diagnostics -- style" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 style1 = %style1%\r\n\\par style2 = %style2%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="1348" Height="597" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <COMMENT Value=" "/> <COMMENT Value="Replace all CRLF within text by octal 02."/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book%" ToReplace="%CRLF%" ReplaceWith="%Octal02%" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <TEXT BOX DISPLAY Title="Diagnostics -- modified text with octal 02" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %book%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="1348" Height="597" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Split out text into paragraphs based on CRLF (which has been replaced by octal 02). "/> <SPLIT STRING Source="%book%" SplitChar="%Octal02%" Dest="%paragraph%" Index="1"/> <TEXT BOX DISPLAY Title="Diagnostics -- paragraphs 1 to 12" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %paragraph[1]%\r\n\\par \r\n\\par %paragraph[2]%\r\n\\par \r\n\\par %paragraph[3]%\r\n\\par \r\n\\par %paragraph[4]%\r\n\\par \\f1 \r\n\\par \\f0 %paragraph[5]%\r\n\\par \r\n\\par %paragraph[6]%\r\n\\par \r\n\\par %paragraph[7]%\r\n\\par \r\n\\par %paragraph[8]%\r\n\\par \r\n\\par %paragraph[9]%\r\n\\par \r\n\\par %paragraph[10]%\r\n\\par \r\n\\par %paragraph[11]%\r\n\\par \r\n\\par %paragraph[12]%\\f1 \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par }\r\n" Left="7" Top="89" Width="1352" Height="596" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Scan paragraphs in array looking for special pattern that we inserted earlier.\r\nMake sure to take the first pattern, so as not to use the extra pattern that\r\nwe inserted at the end. "/> <VARIABLE SET INTEGER Option="\x00" Destination="%paragraph_index%" Value="0"/> <VARIABLE SET INTEGER Option="\x00" Destination="%index_of_paragraph_to_be_moved%" Value="0"/> <REPEAT UNTIL Variable="%paragraph_index%" Condition="\x04" Value="%max_paragraphs%"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%paragraph_index%"/> <IF VARIABLE Variable="%paragraph[%paragraph_index%]%" Condition="\x06" Value="%pattern%" IgnoreCase="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x06" Destination="%index_of_paragraph_to_be_moved%" Variable="%paragraph_index%"/> <REPEAT EXIT/> <END IF/> <END REPEAT/> <TEXT BOX DISPLAY Title="Diagnostics -- paragraph containing pattern" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Paragraph %index_of_paragraph_to_be_moved% contains the marker pattern\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="543" Height="171" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Switch the pattern-marked paragraph with the subsequent paragraph "/> <VARIABLE MODIFY INTEGER Option="\x00" Destination="%index_of_subsequent_paragraph%" Value1="%index_of_paragraph_to_be_moved%" Value2="1"/> <VARIABLE MODIFY STRING Option="\x08" Destination="%temporary_paragraph%" Variable="%paragraph[%index_of_paragraph_to_be_moved%]%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x08" Destination="%paragraph[%index_of_paragraph_to_be_moved%]%" Variable="%paragraph[%index_of_subsequent_paragraph%]%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x08" Destination="%paragraph[%index_of_subsequent_paragraph%]%" Variable="%temporary_paragraph%" NoEmbeddedVars="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Build output text by concatenating paragraphs. \r\nAppend to each paragraph the octal 02 that was removed by the Strip command."/> <VARIABLE SET STRING Option="\x00" Destination="%book1%" NoEmbeddedVars="FALSE"/> <VARIABLE SET INTEGER Option="\x00" Destination="%paragraph_index%" Value="0"/> <REPEAT UNTIL Variable="%paragraph_index%" Condition="\x04" Value="%max_paragraphs%"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%paragraph_index%"/> <IF VARIABLE Variable="%paragraph[%paragraph_index%]%" Condition="\x00" IgnoreCase="FALSE"/> <ELSE/> <VARIABLE MODIFY STRING Option="\x07" Destination="%book1%" Variable="%paragraph[%paragraph_index%]%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x07" Destination="%book1%" Variable="%Octal02%" NoEmbeddedVars="FALSE"/> <END IF/> <END REPEAT/> <VARIABLE SET INTEGER Option="\x0D" Destination="%length_book1%" Text_Variable="%book1%"/> <TEXT BOX DISPLAY Title="Diagnostics -- output rebuilt, but without CRLFs" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Length of original book %length_book%\r\n\\par Length of modified book1 %length_book1%\r\n\\par \r\n\\par %book1%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="1345" Height="613" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Put back the CRLF sequences that we previously converted to octal 02."/> <IF VARIABLE Variable="%style1%" Condition="\x00" Value="TRUE" IgnoreCase="TRUE"/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book1%" ToReplace="%Octal02%" ReplaceWith="%CRLF%" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <ELSE/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book1%" ToReplace="%Octal02%" ReplaceWith="%CRLF%%CRLF%" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <END IF/> <TEXT BOX DISPLAY Title="Diagnostics -- output rebuilt, CRLFs restored" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %book1%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="1345" Height="613" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Remove the marker pattern from the text "/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book1%" ToReplace="%pattern%" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <TEXT BOX DISPLAY Title="Diagnostics -- final output rebuilt, marker patterns removed" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %book1%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="1345" Height="613" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Put the retructured text back into the Notepad area by highlighting all and pasting from clipboard"/> <VARIABLE MODIFY STRING Option="\x10" Destination="%book1%" NoEmbeddedVars="FALSE"/> <TEXT TYPE Action="0" Text="<CTRLD>a<CTRLU>"/> <DELAY Flags="\x12" Time="500"/> <TEXT TYPE Action="0" Text="<CTRLD>v<CTRLU>"/> <COMMENT Value=" "/> <COMMENT Value=" "/> <MACRO RETURN/> <COMMENT Value=" "/>
  14. Often this approach works well for precisely-defined conditions, like what you used it for, and can be done in relatively-few keystrokes. I used to have a wonderful keyboard where you just pressed one of twelve "program" keys, then entered whatever keystrokes you wanted. Basically you could enter a keyboard macro in a matter of seconds, right within the keyboard. My keyboard finally became obsolete because newer computers had no place to plug it in,😧 so I transitioned to Macro Express. ME is vastly more powerful overall, but the programmable keyboard was vastly easier and faster for small keyboard-only sequences. Meanwhile, minor tweaks have made my Notepad macro work with more common document layouts that I mentioned above.
  15. Well, I have a preliminary version working for Notepad. It moves a paragraph down; moving it up would be similar. It requires that the text be typed continuously in Notepad, using the ENTER key only to start a new paragraph. That means the CR-LF sequence exists only at the end of a paragraph. Logic of the macro is first to type an oddball string at the insertion point – wherever the mouse is positioned within the paragraph to be moved down. Then, get the whole document into a variable, and replace every CR-LF with an octal 02, an unprintable character that will never exist in normal text. Replacing CR-LF with a single byte is done because Macro Express needs a single byte for splitting. The text is then split on &02 into array %paragraph%. Each item in the array is searched for the oddball string that the macro initially typed, and when found that array item is swapped with the subsequent one. The items of array %paragraph% are then concatenated to an output string, with CR-LF appended after each paragraph, and the oddball marker string is removed. It works fine when the text follows the constraints I defined. However, when I loaded the text of a book from Project Gutenberg, there was a CR-LF for every line, and paragraphs delineated by double-spacing. More work needed to handle these real-world cases! <COMMENT Value=" "/> <LOG MESSAGES Filename="C:\\Temp\\MacroExpressProLogFiles\\MacroExpressPro_Macro_Log_File.txt" Message="Macro name: Kbyd_Paragraph" Stamp="TRUE"/> <LOG ERRORS Hide_Errors="FALSE"/> <COMMENT Value="Line Feed (New Line) character ascii 10"/> <VARIABLE SET TO ASCII CHAR Value="10" Destination="%LF%"/> <COMMENT Value="Carriage Return character ascii 13"/> <VARIABLE SET TO ASCII CHAR Value="13" Destination="%CR%"/> <COMMENT Value="Carriage Return / Line Feed combination characters ascii 13 + ascii 10"/> <VARIABLE MODIFY STRING Option="\x08" Destination="%CRLF%" Variable="%CR%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x07" Destination="%CRLF%" Variable="%LF%" NoEmbeddedVars="FALSE"/> <COMMENT Value="Octal 01 and 02 "/> <VARIABLE SET TO ASCII CHAR Value="1" Destination="%Octal01%"/> <VARIABLE SET TO ASCII CHAR Value="2" Destination="%Octal02%"/> <COMMENT Value="Pattern to flag paragraph (insertion point) "/> <VARIABLE SET STRING Option="\x00" Destination="%pattern%" Value=")(*()(*()(*()(*()(*()][\\][p" NoEmbeddedVars="FALSE"/> <COMMENT Value="Maximum number of paragraphs to be handled by macro"/> <COMMENT Value="Clear %paragraph% array to hold up to 50 paragraphs "/> <VARIABLE SET INTEGER Option="\x00" Destination="%max_paragraphs%" Value="50"/> <CLEAR VARIABLES Type="Text Variables" Option="\x01" Variable="%paragraph%" Start="1" End="%max_paragraphs%" _COMMENT="clear storage array to hold paragraphs"/> <COMMENT Value=" "/> <COMMENT Value="Text file should be already open in Notepad, with mouse hovering over paragraph which is to be moved down.\r\nInsert funny pattern of characters at insertion point."/> <MOUSE LEFT CLICK/> <TEXT TYPE Action="0" Text="%pattern%"/> <COMMENT Value=" "/> <COMMENT Value="Get Notepad content into veriable %book%. "/> <MACRO RUN Use_ID="FALSE" Name="0_Kybd_Copy_All" ID="-1" Wait="TRUE"/> <VARIABLE SET STRING Option="\x02" Destination="%book%" NoEmbeddedVars="FALSE"/> <DELAY Flags="\x11" Time="2" _ENABLED="FALSE"/> <TEXT BOX DISPLAY Title="Debugging -- display book content with pattern inserted" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %book%\\f1 \r\n\\par }\r\n" Left="25" Top="114" Width="1289" Height="566" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Make sure ESC character does not exist in the text, also no octal 01 or 02"/> <VARIABLE MODIFY STRING Option="\x07" Destination="%book%" Variable="%Octal02%" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/> <IF VARIABLE Variable="%book%" Condition="\x06" Value="%Octal02%" IgnoreCase="FALSE"/> <TEXT BOX DISPLAY Title="Error" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Error: ZIP macro -- text to be compressed already contains the ESC Escape character, or an octal 01 or 02. These characters are not allowed, because they are used for special purposes within this macro.\r\n\\par \r\n\\par Macro aborted. \\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <MACRO RETURN/> <END IF/> <COMMENT Value=" "/> <COMMENT Value="Right-trim the overall text and add another copy of the marker pattern to the end,\r\npreceded by octal 02 so it will be split out as a (dummy) concluding paragraph. "/> <VARIABLE MODIFY STRING Option="\x02" Destination="%book%"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%book%" Value="%Octal02%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%book%" Value="%pattern%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%book%" Value="%Octal02%" NoEmbeddedVars="FALSE" _ENABLED="FALSE"/> <VARIABLE SET INTEGER Option="\x0D" Destination="%length_book%" Text_Variable="%book%"/> <COMMENT Value=" "/> <COMMENT Value="Replace all CRLF within text by octal 02."/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book%" ToReplace="%CRLF%" ReplaceWith="%Octal02%" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <TEXT BOX DISPLAY Title="Diagnostics -- modified text with octal 02" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %book%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="1348" Height="597" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Split out text into paragraphs based on CRLF (which has been replaced by octal 02). "/> <SPLIT STRING Source="%book%" SplitChar="%Octal02%" Dest="%paragraph%" Index="1"/> <TEXT BOX DISPLAY Title="Diagnostics -- paragraphs 1 to 12" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %paragraph[1]%\r\n\\par \r\n\\par %paragraph[2]%\r\n\\par \r\n\\par %paragraph[3]%\r\n\\par \r\n\\par %paragraph[4]%\r\n\\par \\f1 \r\n\\par \\f0 %paragraph[5]%\r\n\\par \r\n\\par %paragraph[6]%\r\n\\par \r\n\\par %paragraph[7]%\r\n\\par \r\n\\par %paragraph[8]%\r\n\\par \r\n\\par %paragraph[9]%\r\n\\par \r\n\\par %paragraph[10]%\r\n\\par \r\n\\par %paragraph[11]%\r\n\\par \r\n\\par %paragraph[12]%\\f1 \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par }\r\n" Left="7" Top="89" Width="1352" Height="596" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Scan paragraphs in array looking for special pattern that we inserted earlier.\r\nMake sure to take the first pattern, so as not to use the extra pattern that\r\nwe inserted at the end. "/> <VARIABLE SET INTEGER Option="\x00" Destination="%paragraph_index%" Value="0"/> <VARIABLE SET INTEGER Option="\x00" Destination="%index_of_paragraph_to_be_moved%" Value="0"/> <REPEAT UNTIL Variable="%paragraph_index%" Condition="\x04" Value="%max_paragraphs%"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%paragraph_index%"/> <IF VARIABLE Variable="%paragraph[%paragraph_index%]%" Condition="\x06" Value="%pattern%" IgnoreCase="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x06" Destination="%index_of_paragraph_to_be_moved%" Variable="%paragraph_index%"/> <REPEAT EXIT/> <END IF/> <END REPEAT/> <TEXT BOX DISPLAY Title="Diagnostics -- paragraph containing pattern" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Paragraph %index_of_paragraph_to_be_moved% contains the marker pattern\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="543" Height="171" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Switch the pattern-marked paragraph with the subsequent paragraph "/> <VARIABLE MODIFY INTEGER Option="\x00" Destination="%index_of_subsequent_paragraph%" Value1="%index_of_paragraph_to_be_moved%" Value2="1"/> <VARIABLE MODIFY STRING Option="\x08" Destination="%temporary_paragraph%" Variable="%paragraph[%index_of_paragraph_to_be_moved%]%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x08" Destination="%paragraph[%index_of_paragraph_to_be_moved%]%" Variable="%paragraph[%index_of_subsequent_paragraph%]%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x08" Destination="%paragraph[%index_of_subsequent_paragraph%]%" Variable="%temporary_paragraph%" NoEmbeddedVars="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Build output text by concatenating paragraphs. \r\nAppend to each paragraph the octal 02 that was removed by the Strip command."/> <VARIABLE SET STRING Option="\x00" Destination="%book1%" NoEmbeddedVars="FALSE"/> <VARIABLE SET INTEGER Option="\x00" Destination="%paragraph_index%" Value="0"/> <REPEAT UNTIL Variable="%paragraph_index%" Condition="\x04" Value="%max_paragraphs%"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%paragraph_index%"/> <IF VARIABLE Variable="%paragraph[%paragraph_index%]%" Condition="\x00" IgnoreCase="FALSE"/> <ELSE/> <VARIABLE MODIFY STRING Option="\x07" Destination="%book1%" Variable="%paragraph[%paragraph_index%]%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x07" Destination="%book1%" Variable="%Octal02%" NoEmbeddedVars="FALSE"/> <END IF/> <END REPEAT/> <VARIABLE SET INTEGER Option="\x0D" Destination="%length_book1%" Text_Variable="%book1%"/> <TEXT BOX DISPLAY Title="Diagnostics -- output rebuilt, but without CRLFs" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Length of original book %length_book%\r\n\\par Length of modified book1 %length_book1%\r\n\\par \r\n\\par %book1%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="1345" Height="613" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Put back the CRLF sequences that we previously converted to octal 02."/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book1%" ToReplace="%Octal02%" ReplaceWith="%CRLF%" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <TEXT BOX DISPLAY Title="Diagnostics -- output rebuilt, CRLFs restored" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %book1%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="1345" Height="613" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Remove the marker pattern from the text "/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%book1%" ToReplace="%pattern%" All="TRUE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <TEXT BOX DISPLAY Title="Diagnostics -- final output rebuilt, marker patterns removed" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %book1%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="1345" Height="613" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/> <COMMENT Value=" "/> <COMMENT Value="Put the retructured text back into the Notepad area by highlighting all and pasting from clipboard"/> <VARIABLE MODIFY STRING Option="\x10" Destination="%book1%" NoEmbeddedVars="FALSE"/> <TEXT TYPE Action="0" Text="<CTRLD>a<CTRLU>"/> <DELAY Flags="\x12" Time="500"/> <TEXT TYPE Action="0" Text="<CTRLD>v<CTRLU>"/> <COMMENT Value=" "/> <COMMENT Value=" "/> <MACRO RETURN/> <COMMENT Value=" "/>
×
×
  • Create New...