Jump to content
Macro Express Forums

acantor

Members
  • Posts

    1,532
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by acantor

  1. SWITCH is a clearer alternative to IF THEN ELSE statements.
  2. Maybe something like this? Variable Set Integer %N1% to 0 Repeat Until %T1% Equals "" // Body of Repeat Loop Variable Modify Integer %N1%: Increment End Repeat // Check the value of %N1%, and decide what to do with it. Switch( %N1% ) Case: 0 // Do this if %N1% = 0 End Case Case: 1 // Do this if %N1% = 1 End Case Case: 2 // Do this if %N1% = 2 End Case Default Case // Do this if %N1% = 3 or more End Case End Switch
  3. A variable is something that represents something else, E.g., x = 2 y = 3 z = x + y = 5 a = "Good" b = "Hi" c = First character in a = "G" d = Number of Characters in b = 2 x, y, and z are numeric variables. a, b, and c are text variables. d is a numeric variable that says something about a text variable. In Macro Express 3, numeric variables always start with the letter N, are followed by a number, and are enclosed in percentage signs: %N1% = 3 %N2% = 7 %N3% = %N1% + %N2% = 10 Text variables always start with the letter T, are followed by a number, and are enclosed in percentage signs: %T1% = "Bye" %T2% = "Happy" %T3% = First character in %T1% = "B" %N4% = Number of Characters in %T2% = 5 I hope this gets you started. The Help in Macro Express explains variables quite well. There are many sample ME3 macros available that illustrate how variables work in real life.
  4. With Macro Express, I know of only two scripting techniques for RELIABLY interacting with a user interface: 1. Manipuate the underlying structure programmatically: Capture and interact with controls. 2. Send a sequence of keystrokes: e.g., <Alt>f = File menu. Any script that clicks on an (x, y) coordinate is bound to fail under certain conditions, such as changing the theme, increasing a font size, displaying an extra toolbar, etc. Mouse macros can work fine, but they are fragile in the sense that it does not take much to break them. If you are willing to put in the time and effort, it is possible to develop Macro Express scripts that make inferences about the user interface by, for example, examining pixel colours, monitoring changes in the shape of the mouse cursor, checking window titles, and analyzing the content of the clipboard. These techniques result in scripts that are not quite as reliable as those that manipulate controls directly or send series of keystrokes. But the results can be pretty good. I described these kinds of scripting techniques in an article I wrote several years ago: http://www.cantoraccess.com/publications/macros_2007_csun_smartmacros.shtml
  5. I think the answer is No. There are several MEP commands and structure that have no equivalents in ME3.
  6. Tough problem. Watch carefully while waiting for the selection to become active, and look for (1) cursor pointer changes, and/or (2) colour changes somewhere in the user interface. If you spot something that is updating, you may be able to infer when the selection is ready by monitoring, for (1), changes to the mouse pointer shape, or for (2), changes in the colour of a particular pixel. Something like this, in pseudo code: // Monitor the shape of the mouse pointer until it is not an hourglass Mouse Mouse to 100, 100 relative to the window Repeat 100 times If Mouse Pointer = hourglass Wait 100 ms Else // The wait is over, so assume selection is ready. // Perform the action. Repeat Break End if Repeat End // Monitor a pixel until it changes to red Mouse Mouse to 200, 200 relative to the window Repeat 100 times If Pixel Colour is NOT Red Wait 100 ms Else // The pixel is red, so assume selection is ready. // Perform the action. Repeat Break End if Repeat End
  7. What you are describing is not an easy macro to script, unless the "Download" link is always exactly in the same position relative to the window or the screen. Assuming the link is at position (100, 200) relative to the window (measured from the top left corner): Mouse Move: 100, 200 Relative to Current Window Mouse Right Click You need a different approach If the link's position changes. Assuming (1) the word "Download" is text (as opposed to an image of text), and (2) the word appears only once per screen, you can do something like this: Text Type (Simulate Keystrokes): <CONTROL>f Text Type (Simulate Keystrokes): Download Text Type (Simulate Keystrokes): <ESC> Text Type (Simulate Keystrokes): <CONTROL>s Basically, this script searches for the word Download, then cancels the search. In Chrome, this action gives keyboard focus to the entire link that contains the search term. Ctrl + S is the keyboard shortcut for "Save," which Chrome supports. You may need short delays between steps. You might discover that this approach works better in Firefox or IE. PS: If you opt the second approach, it will be challenging to move the mouse cursor to the focused link. The Macro Express command that moves the mouse to the text cursor position does not work in web browsers. Right clicking the link will likely be an exercise in frustration! Other keyboard shortcuts that might get you close to a solution, rather than <CONTROL>s, include: 1. Text Type (Simulate Keystrokes): <APP> 2. Text Type (Simulate Keystrokes): <SHIFT><F10> Both the Application key and Shift + F10 are supposed to be keyboard equivalents for right clicking; but my limited experience with Chrome is that they are not exact equivalents: they may bring up a different context menu than one would expect. For this reason, Firefox or IE may be easer to script via Macro Express.
  8. I don't think you can do this in ME3. The "handle" feature in Macro Express Pro *might* make it possible to identify windows that have the same title, but I have had minimal success making it work. It may be possible to rename windows with AutoHotkey and AutoIt, but these programs are not as easy to learn and use as ME and ME Pro.
  9. When you create a new ME macro, you must choose an activation method. Instead of "Hotkey," which is the default, choose "Window title." Then either type in the window title or if the offending window is open, pick it from the "Browse" list. You can chose partial or exact match, and whether the macro is activated when the window opens or gets focus. (gets focus seems to work better in MEP.)
  10. You might want to use a hybrid approach. Create three commands in VBA: one to change the selection to black, another to to red, and the third to blue: Sub Black() Selection.Font.Color = wdColorBlack End Sub Sub Red() Selection.Font.Color = wdColorRed End Sub Sub Blue() Selection.Font.Color = wdColorBlue End Sub Then assign these VBA macros to Word hotkeys: e.g., F2 = Black F3 = Red F4 = Blue If text fragments are stored in Variables, say as an array %Text[n]%... %Text[1]% = This is black. %Text[2]% = This is red. %Text[3]% = This is blue. etc. Then you could do something like this in MEP: Text Type (Simulate Keystrokes): <F2>%Text[1]% ' F2 = black... Text Type (Simulate Keystrokes): <F3>%Text[2]% ' F3 = red... Text Type (Simulate Keystrokes): <F4>%Text[3]% ' F4 = blue... Text Type (Simulate Keystrokes): <F2>%Text[4]% ' Change colour back to black. Kludgy, but it just might work. (Contrary to what many people believe, It is not necessary to select text to change font colours in Word. Text inserted immediately after the execution of the macro will appear in the desired colour.)
  11. MEP has occasional difficulties related to window titles. For example, I do not find that "activation by window title" works as reliably in Pro as in 3.x. It does work... but sometimes not. On some systems, there are intermittent delays before window-title triggered scripts activate. Up-to-date versions of Pro are better in this regard. And I am optimistic that the good folks at Insight Software will sort it out!
  12. Please report the problem. I have experimented with error handling in MEP, but not found the feature particularly reliable, especially the "Halt macro" option. "Prompt for action" works better for me. I will also start reporting error handling problems to Insight.
  13. It's tricky automating tasks in non-standard windows via macros. However, automating tasks in standard windows is also not always easy. It's not unusual to create a script in five minutes that works reliably 95% of the time. To get it to the 99% level can take considerably longer. No macro is 100% reliable. Even a very simple script may fail due to a Windows or application hiccough. When a macro sends to delivers information via the internet, count on it being less reliable. In general, adding time delays is not the best approach. I find "Wait for..." statements work better. (In fact, I find them better in Macro Express 3 than in Pro.) Trial-and-error experimentation is the only way to improve reliability of Macro Express scripts. Be cognizant that there is a point of diminishing returns. If you can bash out a script that is 99% reliable in one hour, are you willing to spend 20 hours to make it work reliably 99.5% of the time? There is no right answer: sometimes the answer is yes, sometimes no. A script that detects when something has gone afoul, and then stops, is worth putting time into when writing complex automation tasks.
  14. The problem of illogically grouped commands seems to be endemic these days. Macro Express is a relatively small program, so it's not too difficult to find what one needs, given trial and error experimentation. The commands may not be organized the way that I would have done it, but it's not a deal breaker for me. For the most part, commands are where I would expect them to be. The problem of zeroing in on commands is more pronounced in complex applications. For me, the logic underlying the organization of the ribbons in Microsoft Word, PowerPoint, etc. is unfathomable. After many years of using Office 2007 and 2010, I still cannot remember or find the commands I occasionally need. I use Macro Express hotkey macros every day to save myself the trouble of hunting for commands, or performing common tasks, in Word, PowerPoint, and Outlook. I estimate these macros save me 20 or 30 minutes per day.
  15. For people who have better ideas of how to organize the commands, ISS gives us the possibility of organizing commands any way we want: Options > Customize Favorites...
  16. 1. Backup your macro file(s) to a safe location. Ditto for your configuration file. (1 minute.) 2. Uninstall the new version, and install the old version. (3 minutes.) 3. Open the macro file(s) and load your configuration file. (1 minute). Test. If there are problems, you still have the backups.
  17. If you include this information, I can tell you how to do it: 1. Nickname of your Macro Express script. 2. How you normally activate the Macro Express script: e.g., pressing a hotkey. (Which key press do you use?) 3. Version of NaturallySpeaking you have, e.g., Professional Version 12, Home Version 11.5, etc.
  18. Maybe something like this? // Initialize counter %N1% Variable Set Integer %N1% to 1 // Repeat loop starts Repeat Start (Repeat 7000 times) // Perform the action // Code goes here // Increment %N1% by 1 Variable Modify Integer: %N1% = %N1% + 1 End Repeat
  19. I see the problem. Good catch! Please report it as a bug to ISS. Maybe describe the problem this way: 1. In the Script Editor, select two or more commands from top to bottom, e.g., Lines 2 through 5. 2. Duplicate the commands. 3. The duplicated lines appear as expected. 4. Unselect the lines. 5. Now, select several lines from bottom to top, e.g., Lines 5 through 2. 6. Duplicate the commands. 7. Only the first topmost line is duplicated. The other selected lines are not copied.
  20. You might find yourself in an infinite loop. A better approach might be to create a macro that repeats another several times. You could even prompt the user to specify the repeat value: Set %Count% from Prompt Repeat %Count% times Macro Run: MyScript End Repeat
  21. One of the things I like about ShortKeys is that there is no need to type the codes into fields. You can type into thin air, the "aether" as it were. As long as the scope is set appropriately, the Shortkey will activate whether or not you see the codes as they are being typed. It's a bit paradoxical and counter intuitive, but it works! However, there can be side-effects of ShortKeys, since by default, Macro Express sends a backspace for each character of the code. For example, typing "degreess<space> causes the backspace key to be pressed nine times. In some contexts, pressing backspace might have an unexpected consequence. In most Web browsers, pressing backspace (when a field is not focused) is the equivalent of clicking the "Back" button. However, In Firefox, it is easy to disable this feature, which opens up the possibility of using Shortkeys without inadvertently going "back" to previously visited pages.
  22. Set Var Integer %N1% from prompt // I will enter the repeat amounts here Set Var Integer %N99% = 1 // This is the counter Repeat %N1% times Clipboard copy Var set string %T%N99%% from clipboard // Example: When %N99% = 1, the value of %T%N99%% is %T1% %N99% = %N99% + 1 // Increment by 1 End Repeat // To paste out the values: Set Var Integer %N99% = 1 // Reset the counter to 1 Repeat %N1% times Type Text %T%N99%% // Move the cursor to the next location, e.g., Type Text <TAB> , Type Text <ENTER>, or whatever %N99% = %N99% + 1 End Repeat
  23. If the appearance of an icon in the System Tray is triggered by the launching of a program or a process, you may be able to accomplish this programmatically by setting the activation to either "Control Event" or "Process Event."
  24. If Macro "A" calls Macro "B", the "Last Run Time" for "A" displays in the Macro Explorer, but the run time for "B" is not updated. For example, I have three macros nicknamed "Address," "Phone Number" and "Branch Office." All three run a macro nicknamed "Landmark on Page." Even though the called macro is activated dozens a time a day, the Last Run Time shows as "Never." When one macro calls another, should the run time of the called macro be updated to record the fact that it was activated? I never thought of this as a bug, but maybe it is. What do others think?
×
×
  • Create New...