Jump to content
Macro Express Forums

acantor

Members
  • Content Count

    874
  • Joined

  • Last visited

  • Days Won

    5

acantor last won the day on April 11 2019

acantor had the most liked content!

Community Reputation

8 Neutral

About acantor

  • Rank
    Master

Contact Methods

  • Website URL
    www.cantoraccess.com
  • ICQ
    0

Profile Information

  • Location
    Toronto

Recent Profile Visitors

615 profile views
  1. This script assigns variables to the x and y coordinates of the mouse pointer relative to... 1. The entire screen 2. The window that has focus Get Mouse Position into (%Screenx%, %Screeny%) Relative to Screen Get Mouse Position into (%Windowx%, %Windowy%) Relative to Current Window <GET MOUSE POSITION Option="\x00" X="%Screenx%" Y="%Screeny%"/> <GET MOUSE POSITION Option="\x01" X="%Windowx%" Y="%Windowy%"/>
  2. In a multi step script, when there is little (or no) or no choice but to check for the presence of particular windows, I use the strategy of using (and reusing) a Boolean variable to signal whether the script is proceeding according to plan: // Section 1 // Wait for "Hello" window to appear Variable Set Bool %IsSuccess% to "False" If Window "Hello" is focused Variable Set Bool %IsSuccess% to "True" End If If Variable %IsSuccess% Equals "False" Text Box Display: Script problem - Section 1 Macro Stop End If // "Hello" window has appeared, perform next action... // Section 2 Variable Set Bool %IsSuccess% to "False" ... If Variable %IsSuccess% Equals "False" Text Box Display: Script problem - Section 2 Macro Stop End If I find this approach very helpful when debugging scripts that are inherently unreliable due to their complexity.
  3. I just tested the "Delete File/Files" instruction in Macro Express 6 in two ways: 1. The file was closed. 2. The file was open. In both cases, Macro Express deleted the file. Delete File/Files: "C:\Users\Test\Documents\tmp tmp tmp.txt"
  4. The cost of Macro Express is fairly modest, and for many (perhaps most) small- and medium-sized organizations, the cost of installing Macro Express on every machine is not prohibitive. Several years ago, I supported an organization whose staff relied on Macro Express. IT deemed that the .mex file must be stored on a network drive. Because the Macro Express files were updated once in a blue moon, and because the users never touched the Macro Express files, I didn't see any particular advantage of storing the .mex file on the network, especially since there were occasional network bottlenecks that caused Macro Express scripts to execute slowly or fail. Placing a copy of Macro Express of each PC would have simplified everything.
  5. Ah ha! I forgot we were talking about the Macro Express Script Editor. Indeed, pressing the down arrow automatically selects the entire next line.
  6. Terry, Are you sure you're not pulling an early April Fool's gag? Terry, because I regard you as an accurate reporter, your finding is very surprising!
  7. Terry, Do you mean that this is what is working? Wait for Window Title "Colour" I don't think this would work for me, as the text of the MEP window title is "Color" not "Colour"! The instruction is actually not 100% necessary. The script should be reliable enough by substituting a short delay for a wait for window instruction.
  8. When you press the arrow key to navigate to a line of text, does pressing Ctrl + c copy the entire line to the clipboard without the need to select the line?
  9. The reason the script isn't working is that there is no code to select the current line. You need to do something like this: <HOME><SHIFT><END> to select the line before copying it to the clipboard
  10. The script can be adapted. Select a line in an MEP script and this script will report if it's a Text Type, If Variable, Message Box, or Comment Clipboard Copy Delay: 100 milliseconds Variable Set String %x% from the clipboard contents If Variable %x% Contains "<TEXT TYPE" Text Box Display: This line is a Type Text! End If If Variable %x% Contains "<IF VARIABLE" Text Box Display: This line is an If Variable! End If If Variable %x% Contains "<MESSAGEBOX" Text Box Display: This line is a Message Box! End If If Variable %x% Contains "<COMMENT" Text Box Display: This line is a Comment! End If // TEST LINES // Check the ability to check the content of an MEP instruction by selecting one of these four lines, then running this macro. MessageBox: Testing Text Type (Simulate Keystrokes): If Variable %x% Contains "<IF VARIABLE" <CLIPBOARD COPY/> <DELAY Flags="\x02" Time="100"/> <VARIABLE SET STRING Option="\x02" Destination="%x%" NoEmbeddedVars="FALSE"/> <COMMENT/> <IF VARIABLE Variable="%x%" Condition="\x06" Value="<TEXT TYPE" IgnoreCase="FALSE"/> <TEXT BOX DISPLAY Title="This line is a Type Text!" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <END IF/> <COMMENT/> <IF VARIABLE Variable="%x%" Condition="\x06" Value="<IF VARIABLE" IgnoreCase="FALSE"/> <TEXT BOX DISPLAY Title="This line is an If Variable!" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <END IF/> <COMMENT/> <IF VARIABLE Variable="%x%" Condition="\x06" Value="<MESSAGEBOX" IgnoreCase="FALSE"/> <TEXT BOX DISPLAY Title="This line is a Message Box!" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <END IF/> <COMMENT/> <IF VARIABLE Variable="%x%" Condition="\x06" Value="<COMMENT" IgnoreCase="FALSE"/> <TEXT BOX DISPLAY Title="This line is a Comment!" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <END IF/> <COMMENT/> <COMMENT/> <COMMENT Value="TEST LINES"/> <COMMENT Value="Check the ability to check the content of an MEP instruction by selecting one of these four lines, then running this macro." _BACK="0080FFFF"/> <MESSAGEBOX Caption="Testing" Message="%x%" Icon="0" _ENABLED="FALSE" _BACK="0080FFFF"/> <TEXT TYPE Action="0" _ENABLED="FALSE" _BACK="0080FFFF"/> <IF VARIABLE Variable="%x%" Condition="\x06" Value="<IF VARIABLE" IgnoreCase="FALSE" _ENABLED="FALSE" _BACK="0080FFFF"/>
  11. My code can be easily modified so you don't need Boolean variables. Variable Set Integer %FakeBool% to 0 // 0 = FALSE, 1 = TRUE Variable Set Integer %LineCount% to 0 Text Type (Simulate Keystrokes): <CONTROL>f // Find start of section Delay: 200 milliseconds Text Type (Simulate Keystrokes): <section Text Type (Simulate Keystrokes): <ENTER> Text Type (Simulate Keystrokes): <ESC> Repeat Until %FakeBool% Equals "1" // Check each line for end of section Text Type (Simulate Keystrokes): <HOME><SHIFT><END> // Select entire line Clipboard Copy Text Type (Simulate Keystrokes): <END><ARROW RIGHT> // Deselect line and go to start of next line If Clipboard Contains "</section>" Variable Set Integer %FakeBool% to 1 End If Variable Modify Integer %LineCount%: Increment End Repeat Text Type (Simulate Keystrokes): <END> // Select the section, starting at end of line Repeat Start (Repeat %LineCount% times) Text Type (Simulate Keystrokes): <SHIFT><ARROW UP> // Select up one line End Repeat Text Type (Simulate Keystrokes): <SHIFT><HOME> // Select to start of first line of section Text Type (Simulate Keystrokes): <DELETE> // Delete the selection <VARIABLE SET INTEGER Option="\x00" Destination="%FakeBool%" Value="0" _COMMENT="0 = FALSE, 1 = TRUE"/> <VARIABLE SET INTEGER Option="\x00" Destination="%LineCount%" Value="0"/> <COMMENT/> <TEXT TYPE Action="0" Text="<CONTROL>f" _COMMENT="Find start of section"/> <DELAY Flags="\x02" Time="200"/> <TEXT TYPE Action="0" Text="<section"/> <TEXT TYPE Action="0" Text="<ENTER>"/> <TEXT TYPE Action="0" Text="<ESC>"/> <COMMENT/> <REPEAT UNTIL Variable="%FakeBool%" Condition="\x00" Value="1" _COMMENT="Check each line for end of section"/> <TEXT TYPE Action="0" Text="<HOME><SHIFT><END>" _COMMENT="Select entire line"/> <CLIPBOARD COPY/> <TEXT TYPE Action="0" Text="<END><ARROW RIGHT>" _COMMENT="Deselect line and go to start of next line"/> <IF CLIPBOARD Option="\x01" Text="</section>" CaseSensitive="FALSE"/> <VARIABLE SET INTEGER Option="\x00" Destination="%FakeBool%" Value="1"/> <END IF/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%LineCount%"/> <END REPEAT/> <COMMENT/> <TEXT TYPE Action="0" Text="<END>" _COMMENT="Select the section, starting at end of line"/> <REPEAT START Start="1" Step="1" Count="%LineCount%" Save="FALSE"/> <TEXT TYPE Action="0" Text="<SHIFT><ARROW UP>" _COMMENT="Select up one line"/> <END REPEAT/> <TEXT TYPE Action="0" Text="<SHIFT><HOME>" _COMMENT="Select to start of first line of section"/> <COMMENT/> <TEXT TYPE Action="0" Text="<DELETE>" _COMMENT="Delete the selection"/>
  12. My script runs a little faster if you change this: Variable Set String %Text% from the clipboard contents If Variable %Text% Contains "</section>" to this: If Clipboard Contains "</section>"
  13. No need to repeat these repetitive steps. Write a macro! Here is the MEP script I use to change the background colour of selected lines to yellow. As I read through the code, I don't remember why the line to "unfurl" the Edit menu is there. I've been using the macro for years, and my guess is that the line is superfluous. But you can test that yourself! Anyways, you can adapt the script to format or set Macro Express instructions anyway you like. Text Type (Simulate Keystrokes): <ALT>e // Activate &Edit menu Delay: 100 milliseconds Text Type (Simulate Keystrokes): <ARROW UP><ARROW DOWN> // Unfurl menu... Text Type (Simulate Keystrokes): <END> // Go to last item on menu Repeat Start (Repeat 6 times) // Select "Background Color" Text Type (Simulate Keystrokes): <ARROW UP> End Repeat Text Type (Simulate Keystrokes): <ENTER> Wait for Window Title: Color Text Type (Simulate Keystrokes): <HOME> // Go to top left corner... Text Type (Simulate Keystrokes): <ARROW RIGHT> // Navigate to Yellow Text Type (Simulate Keystrokes): <SPACE> // Select Yellow Text Type (Simulate Keystrokes): <ENTER> // Done! <TEXT TYPE Action="0" Text="<ALT>e" _COMMENT="Activate &Edit menu"/> <DELAY Flags="\x02" Time="100"/> <TEXT TYPE Action="0" Text="<ARROW UP><ARROW DOWN>" _COMMENT="Unfurl menu..."/> <TEXT TYPE Action="0" Text="<END>" _COMMENT="Go to last item on menu"/> <REPEAT START Start="1" Step="1" Count="6" Save="FALSE" _COMMENT="Select \"Background Color\""/> <TEXT TYPE Action="0" Text="<ARROW UP>"/> <END REPEAT/> <TEXT TYPE Action="0" Text="<ENTER>"/> <WAIT FOR WINDOW TITLE Title="Color" Partial="FALSE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="2"/> <TEXT TYPE Action="0" Text="<HOME>" _COMMENT="Go to top left corner..."/> <TEXT TYPE Action="0" Text="<ARROW RIGHT>" _COMMENT="Navigate to Yellow"/> <TEXT TYPE Action="0" Text="<SPACE>" _COMMENT="Select Yellow" _BACK="0080FFFF"/> <TEXT TYPE Action="0" Text="<ENTER>" _COMMENT="Done!"/>
  14. If the button is always in the same position, try moving the pointer and clicking relative to the window instead of relative to the screen.
  15. This brute force method isn't fast. The macro will fail, maybe spectacularly, if the document does not contain "<section" or "</section" But hoping this will get you started. Variable Set Bool %SectionEndFound% to "False" Variable Set Integer %LineCount% to 0 Text Type (Simulate Keystrokes): <CONTROL>f // Find start of section Delay: 200 milliseconds Text Type (Simulate Keystrokes): <section Text Type (Simulate Keystrokes): <ENTER> Text Type (Simulate Keystrokes): <ESC> Repeat Until %SectionEndFound% Equals "True" // Check each line for end of section Text Type (Simulate Keystrokes): <HOME><SHIFT><END> // Select entire line Clipboard Copy Text Type (Simulate Keystrokes): <END><ARROW RIGHT> // Deselect line and go to start of next line Variable Set String %Text% from the clipboard contents If Variable %Text% Contains "</section>" Variable Set Bool %SectionEndFound% to "True" End If Variable Modify Integer %LineCount%: Increment End Repeat Text Type (Simulate Keystrokes): <END> // Select the section, starting at end of line Repeat Start (Repeat %LineCount% times) Text Type (Simulate Keystrokes): <SHIFT><ARROW UP> // Select up one line End Repeat Text Type (Simulate Keystrokes): <SHIFT><HOME> // Select to start of first line of section Text Type (Simulate Keystrokes): <DELETE> // Delete the selection <VARIABLE SET BOOL Destination="%SectionEndFound%" Command="263" Value="FALSE"/> <VARIABLE SET INTEGER Option="\x00" Destination="%LineCount%" Value="0"/> <COMMENT/> <TEXT TYPE Action="0" Text="<CONTROL>f" _COMMENT="Find start of section"/> <DELAY Flags="\x02" Time="200"/> <TEXT TYPE Action="0" Text="<section"/> <TEXT TYPE Action="0" Text="<ENTER>"/> <TEXT TYPE Action="0" Text="<ESC>"/> <COMMENT/> <REPEAT UNTIL Variable="%SectionEndFound%" Condition="\x00" Value="True" _COMMENT="Check each line for end of section"/> <TEXT TYPE Action="0" Text="<HOME><SHIFT><END>" _COMMENT="Select entire line"/> <CLIPBOARD COPY/> <TEXT TYPE Action="0" Text="<END><ARROW RIGHT>" _COMMENT="Deselect line and go to start of next line"/> <VARIABLE SET STRING Option="\x02" Destination="%Text%" NoEmbeddedVars="FALSE"/> <IF VARIABLE Variable="%Text%" Condition="\x06" Value="</section>" IgnoreCase="FALSE"/> <VARIABLE SET BOOL Destination="%SectionEndFound%" Command="263" Value="TRUE"/> <END IF/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%LineCount%"/> <END REPEAT/> <COMMENT/> <TEXT TYPE Action="0" Text="<END>" _COMMENT="Select the section, starting at end of line"/> <REPEAT START Start="1" Step="1" Count="%LineCount%" Save="FALSE"/> <TEXT TYPE Action="0" Text="<SHIFT><ARROW UP>" _COMMENT="Select up one line"/> <END REPEAT/> <TEXT TYPE Action="0" Text="<SHIFT><HOME>" _COMMENT="Select to start of first line of section"/> <COMMENT/> <TEXT TYPE Action="0" Text="<DELETE>" _COMMENT="Delete the selection"/>
×
×
  • Create New...