Jump to content
Macro Express Forums

acantor

Members
  • Posts

    1,233
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by acantor

  1. Hi Sebastian, My impression is that the Macro Express aficionados who haunt this forum gravitate to Macro Express not because it's a super-efficient, leading-edge programming environment, but because it's a useful, interesting, and quirky tool that non-programmers can sink their teeth into and get excellent results. Many if not most people who are "into" Macro Express, I would guess, understand, accept, and even embrace its limitations. Macro Express is almost always my first choice when there's a task I want to automate, simplify, or improve. That's because I can often create working prototypes in minutes. But I don't use Macro Express for everything. For some tasks, other tools are clearly better. For example, I once automated a task using AutoHotkey, and using Macro Express. The AutoHotkey version runs in the blink of an eye, while the Macro Express version runs in slow motion. Although the AutoHotkey version is more practical, I sometimes opt to use the Macro Express version because I'm proud that I was able to make it work, despite Macro Express's constraints. The beauty of Macro Express, for me, is that its constraints spark creativity.
  2. I'm not sure how to copy an entire folder. But it's possble to copy the content of an entire folder: Copy File/Files: "C:\Users\Alan\Documents\Test\*.*" to "C:\Users\Alan\Documents\Test\Testing\" <COPY FILE/FILES Source="C:\\Users\\Alan\\Documents\\Test\\*.*" Dest="C:\\Users\\Alan\\Documents\\Test\\Testing\\" Progress="TRUE" Recurse="FALSE"/> Star-dot-star is a wildcard that represents all files contained in folder C:\Users\Alan\Documents\Test If you only need to copy a single file, you can do the following, which copies the file called "File.txt" into the "Testing" sub-folder. Copy File/Files: "C:\Users\Alan\Documents\Test\File.txt" to "C:\Users\Alan\Documents\Test\Testing\" <COPY FILE/FILES Source="C:\\Users\\Alan\\Documents\\Test\\File.txt" Dest="C:\\Users\\Alan\\Documents\\Test\\Testing\\" Progress="TRUE" Recurse="FALSE"/>
  3. There's a lot to learn of while getting comfortable with Macro Express. Your learning curve is typical! The second field from the top is currently blank. Macro Express needs to know the name of the variable that will store the date. The variable name I suggested in my original response was %Date%. So in the second field from the top, type in: %Date% Alternatively, click the "Variable" button next to the field. If you navigate around enough, you may find it there. Or you may be forced to create a new text variable. Overall, through, I think it's easier just to type %Date% in the field. If the variable %Date% doesn't exist, Macro Express will prompt you to create it when you save the macro.
  4. You are so on the right track! Change the value in the drop-down list from: "Type the date/time stamp out" to "Store the date/time stamp as a variable" The item currently selected outputs the date as though you were typing it. The item you want stores the date. By storing it, you can output the date twice: first, when you rename the file, and second, when you move the file.
  5. The variable %Date% in Line 1 is not defined. Edit the instruction, go to the "Operations" tab, and choose to store the date as text variable %Date%. Line 3 renames a file called "a:\Data". But is that really the name of the file? If the file name has an extension, you must include it in the file name: Data.txt, Data.doc, Data.xml, or whatever.
  6. I don't think the lack of delays is the problem, although short delays may be needed in the end. Here are the issues that are preventing the macro from working that I've spotted: Line 2: This is not a statement that sets a variable. It's a statement to type out text. Delete the line, and recreate it from scratch: Variables > Date/Time. Lines 4 and 6: There are quote marks around the file names that shouldn't be there. Edit the lines and delete the quote marks from the files names. In other words, change: "a:\Data" to a:\Data Also, these changes will be easier to do with "Direct Editor" mode toggled OFF. Not sure if this is what is what is happening, but thought I'd mention it. This setting is in the "View" menu in the Script Editor.
  7. Might it be possible to rename and move using Macro Express commands? Manipulating a user interface to perform these tasks might get flaky! Maybe something like this untested example? Date/Time: Set %Date% to the current date/time using "YYYY-MM-dd" as the format Rename File/Files: "c:\tmp\Data" to "c:\tmp\%Date%" Move File/Files: "c:\tmp\%Date%" to "c:\DataOld\%Date%"
  8. Hi Stephen, The clarity of your explanations made it easy to figure out what was holding you back. There is a lot to puzzle out when learning to script macros. Hopefully you've arrived at the next level!
  9. It sounds like the problem may be the method you entered the third line of code. Try doing it this way: 0. Delete third line from your script. 1. From the list of categories on the left side of the screen, choose "Windows/Programs" 2. From the group, choose "Window Resize." This should cause the "Window Resize" window to appear. 3. In the Window Resize window, double check that "Use the current window" is selected. 4. Type in the two variable names for width and height, as indicated. Save your macro, open a window you want to resize, and press Ctrl + F.
  10. The rectangle means the folder has focus, but is not selected. Ctrl + spacebar toggles between selection and focus. PS: If you don't need to toggle between the two states (and you probably don't), pressing the space bar will select the focused folder. PPS: No need to right-click to rename. Once the folder is selected, press F2 to rename.
  11. Hi Stephen, It sounds like you did everything right. If you open the macro in the Script Editor, the code should look something like this: Question: What activation did you choose for your macro?
  12. Press the spacebar instead of the Enter key to activate the control. Does that help?
  13. My only suggestion is to insert a short delay between each step, say 300 ms. If that doesn't help, not sure what else to suggest... except to substitute a Mouse Move (relative to the window, not the screen) and a Left Mouse Click.
  14. As soon as I got my "quick-and-dirty" macro working, I realized I wanted a general solution, i.e., a way to recognize any email address regardless of how it is formatted. In other words, I wanted a macro that would extract any properly-formed email address. I assume these are the rules for a properly-formed email address: left@right It's got an @-sign sandwiched between the left side and the right side. These characters are legal on both sides: A through Z (both cases) 0 through 9 . (period) - (hyphen) _ (underscore) However, the last character on the right side cannot be a period, hyphen, or underscore. To make a long story short, after a lot of work, I came up with a solution that does the heavy-lifting entirely in variable-space. But instead of knocking it out in 15 or 20 minutes, as I did for the original solution, this version took 15 or 20 hours to work out the kinks. And I'm sure there are still ways to improve it. // Macro to "scrape" email addresses from selected text // How to use it: // 1. Select text that contains email addresses. // 2. Run this macro. // 3. The list of email addresses will replace the selected text. // How it works (simplified) // 0. Copy selected text to variable %Clip% for processing. // 1. Find leftmost @-sign in %Clip%. // 2. Parse left from @ until illegal character encountered. Capture legal characters in %LeftReversed% // 3. Reverse %LeftReversed%. That will be the left side of the email address, %Left% // 4. Parse right from @ until an illegal character is found. Capture legal characters in %Right% // 5. %Result% = %Left%@%Right% // 6. Store results. Delete the first @-sign in %Clip%. // 7. Repeat Steps 1 through 6 until all @-signs have been deleted. // Legal characters for email addresses Variable Set String %LegalChars% to "abcdefghijklmnopqrstuvwxyz1234567890._-" // Three legal characters cannot appear in the last position: period, hyphen, and underscore Variable Set String %IllegalLastChars% to "._-" Clipboard Copy Variable Set String %Clip% from the clipboard contents Variable Set String %Clip% to "john@johnny.ca, Sandy Smith <sandy@smith.com>; alan@cantoraccess.com." // Test Variable Set String %Clip% to "*%Clip%*" // Add an "illegal" character to the start and end of %Clip% // Loop through %Clip% until all @-signs are processed Repeat Until %Clip% Does not Contain "@" // Get position of first @-sign Variable Set Integer %CharsToAtSign% to the position of "@" in %Clip% Variable Set Integer %Count% to %CharsToAtSign% // Parse by character <-- RIGHT to LEFT, from the @-sign, until an illegal character is encountered Repeat Start (Repeat %CharsToAtSign% times) Variable Modify Integer %Count%: Decrement Variable Modify String: Copy part of text in %Clip% starting at %Count% and 1 characters long to %Char% If Variable %LegalChars% Contains "%Char%" Variable Modify String %LeftReversed%: Append Text (%Char%) Else Repeat Exit End If End Repeat // Reverse the order of %LeftReversed% to produce %Left%, the left side of the email address Variable Set Integer %LeftLength% to the length of variable %LeftReversed% Repeat Start (Repeat %LeftLength% times) Variable Modify String: Copy part of text in %LeftReversed% starting at %LeftLength% and 1 characters long to %Char% Variable Modify String %Left%: Append Text (%Char%) Variable Modify Integer: %LeftLength% = %LeftLength% - 1 End Repeat // Parse by character --> RIGHT to LEFT, from the @-sign, until an illegal character is encountered Variable Modify Integer: %CharsToAtSign% = %CharsToAtSign% + 1 Variable Set Integer %Pointer% to %CharsToAtSign% Variable Set Integer %ClipLength% to the length of variable %Clip% Variable Modify Integer: %MaxCharsToCheck% = %ClipLength% - %CharsToAtSign% Repeat Start (Repeat %MaxCharsToCheck% times) Variable Modify String: Copy part of text in %Clip% starting at %Pointer% and 1 characters long to %Char% If Variable %LegalChars% Contains "%Char%" Variable Modify String %Right%: Append Text (%Char%) Variable Modify Integer %Pointer%: Increment Else Repeat Exit End If End Repeat // Handle illegal characters in the last position in %Right% Variable Set Integer %RightLength% to the length of variable %Right% Variable Modify String: Copy part of text in %Right% starting at %RightLength% and 1 characters long to %Char% If Variable %IllegalLastChars% Contains "%Char%" Variable Modify String: Delete part of text from %Right% starting at %RightLength% and 1 characters long End If // Construct email address: %Left%@%Right% and store all addresses in %Results% Variable Set String %Result% to "%Left%@%Right%" Variable Modify String %Results%: Append Text (%Result% ) Text Box Display: Result // Delete the @-sign identified above from %Clip% Variable Modify String: Replace "@" in %Clip% with "" // Prepare for the next iteration Variable Set String %Left% to "" Variable Set String %LeftReversed% to "" Variable Set String %Right% to "" End Repeat Text Type (Use Clipboard and Paste Text): %Results% <COMMENT Value="Macro to \"scrape\" email addresses from selected text"/> <COMMENT/> <COMMENT Value="How to use it:"/> <COMMENT Value="1. Select text that contains email addresses."/> <COMMENT Value="2. Run this macro."/> <COMMENT Value="3. The list of email addresses will replace the selected text."/> <COMMENT/> <COMMENT Value="How it works (simplified)"/> <COMMENT Value=" 0. Copy selected text to variable %Clip% for processing."/> <COMMENT Value=" 1. Find leftmost @-sign in %Clip%."/> <COMMENT Value=" 2. Parse left from @ until illegal character encountered. Capture legal characters in %LeftReversed%"/> <COMMENT Value=" 3. Reverse %LeftReversed%. That will be the left side of the email address, %Left%"/> <COMMENT Value=" 4. Parse right from @ until an illegal character is found. Capture legal characters in %Right%"/> <COMMENT Value=" 5. %Result% = %Left%@%Right% "/> <COMMENT Value=" 6. Store results. Delete the first @-sign in %Clip%."/> <COMMENT Value=" 7. Repeat Steps 1 through 6 until all @-signs have been deleted."/> <COMMENT/> <COMMENT Value="Legal characters for email addresses"/> <VARIABLE SET STRING Option="\x00" Destination="%LegalChars%" Value="abcdefghijklmnopqrstuvwxyz1234567890._-" NoEmbeddedVars="FALSE"/> <COMMENT Value="Three legal characters cannot appear in the last position: period, hyphen, and underscore"/> <VARIABLE SET STRING Option="\x00" Destination="%IllegalLastChars%" Value="._-" NoEmbeddedVars="FALSE"/> <COMMENT/> <CLIPBOARD COPY/> <VARIABLE SET STRING Option="\x02" Destination="%Clip%" NoEmbeddedVars="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%Clip%" Value="john@johnny.ca, Sandy Smith <sandy@smith.com>; alan@cantoraccess.com." NoEmbeddedVars="FALSE" _ENABLED="FALSE" _COMMENT="Test"/> <COMMENT/> <VARIABLE SET STRING Option="\x00" Destination="%Clip%" Value="*%Clip%*" NoEmbeddedVars="FALSE" _COMMENT="Add an \"illegal\" character to the start and end of %Clip%"/> <COMMENT/> <COMMENT Value="Loop through %Clip% until all @-signs are processed"/> <REPEAT UNTIL Variable="%Clip%" Condition="\x07" Value="@"/> <COMMENT/> <COMMENT Value="Get position of first @-sign"/> <VARIABLE SET INTEGER Option="\x0E" Destination="%CharsToAtSign%" Text_Variable="%Clip%" Text="@" Ignore_Case="FALSE"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Count%" Value="%CharsToAtSign%"/> <COMMENT/> <COMMENT Value="Parse by character <-- RIGHT to LEFT, from the @-sign, until an illegal character is encountered"/> <REPEAT START Start="1" Step="1" Count="%CharsToAtSign%" Save="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x08" Destination="%Count%"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Clip%" Start="%Count%" Count="1" NoEmbeddedVars="FALSE"/> <IF VARIABLE Variable="%LegalChars%" Condition="\x06" Value="%Char%" IgnoreCase="TRUE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%LeftReversed%" Value="%Char%" NoEmbeddedVars="FALSE"/> <ELSE/> <REPEAT EXIT/> <END IF/> <END REPEAT/> <COMMENT/> <COMMENT Value="Reverse the order of %LeftReversed% to produce %Left%, the left side of the email address"/> <VARIABLE SET INTEGER Option="\x0D" Destination="%LeftLength%" Text_Variable="%LeftReversed%"/> <REPEAT START Start="1" Step="1" Count="%LeftLength%" Save="FALSE"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%LeftReversed%" Start="%LeftLength%" Count="1" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Left%" Value="%Char%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x01" Destination="%LeftLength%" Value1="%LeftLength%" Value2="1"/> <END REPEAT/> <COMMENT/> <COMMENT Value="Parse by character --> RIGHT to LEFT, from the @-sign, until an illegal character is encountered"/> <VARIABLE MODIFY INTEGER Option="\x00" Destination="%CharsToAtSign%" Value1="%CharsToAtSign%" Value2="1"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Pointer%" Value="%CharsToAtSign%"/> <VARIABLE SET INTEGER Option="\x0D" Destination="%ClipLength%" Text_Variable="%Clip%"/> <VARIABLE MODIFY INTEGER Option="\x01" Destination="%MaxCharsToCheck%" Value1="%ClipLength%" Value2="%CharsToAtSign%"/> <COMMENT/> <REPEAT START Start="1" Step="1" Count="%MaxCharsToCheck%" Save="FALSE"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Clip%" Start="%Pointer%" Count="1" NoEmbeddedVars="FALSE"/> <IF VARIABLE Variable="%LegalChars%" Condition="\x06" Value="%Char%" IgnoreCase="TRUE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Right%" Value="%Char%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%Pointer%"/> <ELSE/> <REPEAT EXIT/> <END IF/> <END REPEAT/> <COMMENT/> <COMMENT Value="Handle illegal characters in the last position in %Right% "/> <VARIABLE SET INTEGER Option="\x0D" Destination="%RightLength%" Text_Variable="%Right%"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Right%" Start="%RightLength%" Count="1" NoEmbeddedVars="FALSE"/> <IF VARIABLE Variable="%IllegalLastChars%" Condition="\x06" Value="%Char%" IgnoreCase="FALSE"/> <VARIABLE MODIFY STRING Option="\x0A" Destination="%Right%" Start="%RightLength%" Count="1"/> <END IF/> <COMMENT/> <COMMENT Value="Construct email address: %Left%@%Right% and store all addresses in %Results%"/> <VARIABLE SET STRING Option="\x00" Destination="%Result%" Value="%Left%@%Right%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%Results%" Value="%Result%\r\n" NoEmbeddedVars="FALSE"/> <TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\lang4105\\f0\\fs28 %Result%\r\n\\par }\r\n" Left="821" Top="417" Width="1014" Height="216" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE" _BACK="0080FFFF"/> <COMMENT/> <COMMENT Value="Delete the @-sign identified above from %Clip%"/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%Clip%" ToReplace="@" All="FALSE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <COMMENT/> <COMMENT Value="Prepare for the next iteration"/> <VARIABLE SET STRING Option="\x00" Destination="%Left%" NoEmbeddedVars="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%LeftReversed%" NoEmbeddedVars="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%Right%" NoEmbeddedVars="FALSE"/> <COMMENT/> <END REPEAT/> <COMMENT/> <TEXT TYPE Action="1" Text="%Results%"/>
  15. Well, this challenge didn't exactly break the internet! I came up with two solutions. The first solution appears in this post, and the second is in the next. The first solution is what I had in mind when I posted the challenge. It's a "quick and dirty" way to strip out text that doesn't form part of an email address. The reason it was relatively easy to script is that the addresses appeared in only four formats. In two of the formats, the less-than sign always marks the start of the email address, and the greater-than sign always marks its end. So the handling of both was identical. email@address <email@address> Name <email@address> Not an email address The macro only took 10 or 15 minutes to prepare, and saved me 45 minutes or an hour of repetitive drudgery. The macro acts on ten email addresses at a time, so although much quicker than making the repairs by hand, the macro is still fairly manual. // Clean-up 10 email addresses by deleting non-email address text Repeat Start (Repeat 10 times) Clipboard Empty Text Type (Simulate Keystrokes): <END><SHIFT><HOME> // Select the line Text Type (Simulate Keystrokes): <CONTROL>c Variable Set String %Clip% from the clipboard contents If Variable %Clip% Does not Contain "@" Text Type (Simulate Keystrokes): <BACKSPACE> Else If Variable %Clip% Contains "<" // Handle email address wrapped with < and > Variable Set Integer %LessThanPos% to the position of "<" in %Clip% Variable Modify String: Delete part of text from %Clip% starting at 1 and %LessThanPos% characters long Variable Modify String: Replace ">" in %Clip% with "" Text Type (Simulate Keystrokes): %Clip% End If End If Text Type (Simulate Keystrokes): <ARROW DOWN> End Repeat <COMMENT Value="Clean-up 10 email addresses by deleting non-email address text"/> <REPEAT START Start="1" Step="1" Count="10" Save="FALSE"/> <CLIPBOARD EMPTY/> <TEXT TYPE Action="0" Text="<END><SHIFT><HOME>" _COMMENT="Select the line"/> <TEXT TYPE Action="0" Text="<CONTROL>c"/> <VARIABLE SET STRING Option="\x02" Destination="%Clip%" NoEmbeddedVars="FALSE"/> <IF VARIABLE Variable="%Clip%" Condition="\x07" Value="@" IgnoreCase="FALSE"/> <TEXT TYPE Action="0" Text="<BACKSPACE>"/> <ELSE/> <IF VARIABLE Variable="%Clip%" Condition="\x06" Value="<" IgnoreCase="FALSE" _COMMENT="Handle email address wrapped with < and >"/> <VARIABLE SET INTEGER Option="\x0E" Destination="%LessThanPos%" Text_Variable="%Clip%" Text="<" Ignore_Case="FALSE"/> <VARIABLE MODIFY STRING Option="\x0A" Destination="%Clip%" Start="1" Count="%LessThanPos%"/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%Clip%" ToReplace=">" All="FALSE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/> <TEXT TYPE Action="0" Text="%Clip%"/> <END IF/> <END IF/> <TEXT TYPE Action="0" Text="<ARROW DOWN>"/> <END REPEAT/>
  16. Tab works if focus begins in the Search field. Otherwise, you'll need to "landmark" on a fixed object before tabbling. Perhaps this? Ctrl + F (Search text box) Tab or Alt + D (Address bar) Tab Tab
  17. The OP did mention that he's using an older version of Firefox. So hotkeys and key sequences might be different.
  18. Maybe the 250 ms delay is not enough. This sequence of keystrokes also navigates to "Import and Backup"... Alt + O // Organize Left arrow Is it possible the hotkey you have assigned to start this process conflicts with another hotkey? Have you created a different macro that is triggered by pressing Alt + i ? If it's truly a focus problem -- and I notice more focus-related issues in Windows 10 than in any previous version of Windows -- adding this step after calling up the Library window might help: Window Activate: Library <WINDOW ACTIVATE Title="Library" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
  19. The hotkey for Test Run is F9, and the "OK" button is activated by pressing Enter. So press F9 followed immediately by Enter. Or, there is a setting that prevents the "Start Debugger" window from appearing:
  20. Text Type (Simulate Keystrokes): <ALTD>I<ALTU> (import/backup) I wonder whether the capitalized "i" is the problem. You may be sending Alt + Shift + i instead of Alt + i. So experiment with these two alternatives: Text Type (Simulate Keystrokes): <ALTD>i<ALTU> or Text Type (Simulate Keystrokes): <ALT>i
  21. It's been a very long time since I last wrote or used a batch file! Is it possible that the failure is due to the batch file running before Macro Express is ready? To troubleshoot, temporarily remove the batch file from the start up group. Manually run the batch file AFTER you are certain Macro Express is loaded. Ensure Macro Express in the startup group. When Macro Express is fully loaded, its icon will be in the System Tray. Also, assuming your macro is hotkey activated, check whether it runs reliably and consistently when you press the hotkey.
  22. This challenge is arguably more of a mid-week diversion than a real challenge. But I thought others might enjoy this not-too-hard puzzle. I recently updated an email mailing list consisting of about 1000 addresses. The list looked like this... Note that each line appears in one of four formats: Name <email@address> <email@address> email@address not an email address (e.g., #Bingo!) The challenge: use Macro Express to simplify the task of cleaning up the 1000 lines so that each line consists only of an email address: Any line that is not an email address, such as "#Bingo!" or a blank line, should be removed.
  23. This might be an important clue. Please describe how you call the macro from a batch file. Is the only time you need to run this macro when you start your computer?
  24. A macro that interacts with an application's user interface cannot be 100% reliable. There are endless ways things can go wrong: a program might fail to launch, a screen might not appear in time, another application might steal focus, and so on. So if your macro ALMOST always works, consider it a success!
×
×
  • Create New...