Jump to content
Macro Express Forums

acantor

Members
  • Posts

    1,532
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by acantor

  1. These kinds of macros are notoriously challenging to script, especially if they run in a web browser. My advice is to build the macro step by step. After you get the first part to work, test repeatedly, and try to make it fail. Then add one more step. Don't hesitate to change your scripting approach; usually there are many ways to automate a process, and some may prove to be more reliable than others. Expect to be picking away at the problem for a long time before you have success. If this is your first attempt at this kind of macro, you probably won't crack it right away. But as it is written in the I Ching, "Perseverance Furthers." Approaches that I have found helpful when developing macros that monitor pixel colour changes in Web browsers include: 1. I find it more reliable to position the mouse cursor over the pixel at (x, y) than to monitor the (x, y) coordinate without the mouse cursor. The reason is that colours may be different when the mouse is hovering over than when it is not. 2. Reliability trumps elegance. You are correct that "Repeat Until" is the way to go, but it has downsides. What if the condition never occurs, as happens all too frequently when network bottlenecks prevent webpages from loading? You may find that it is more reliable to use "Repeat Count" instead, and check the target pixel for, say, 30 seconds (which might be 5000 or 10,000 loops). If you do it this way, it is easy to insert messages that indicate at what step things went wrong. 3. When checking pixel colours in a repeat loop, I sometimes find it necessary to insert a short delay; in other contexts, the delays are unnecessary; and once in a while, relatively long (1000-1500 ms) delays are essential. You can only find out through trial and error experimentation. 4. As rberg suggests, "nudging" the mouse pointer a few pixels back and forth sometimes helps. As above, it takes experimentation to figure it out. Good luck with it!
  2. Try this: // First click Mouse Move Windows 747, 682 // Where to click 1 Delay 100 Milliseconds Mouse Left Button Click // // Second click Mouse Move Windows 747, 682 // Where to click 2 Repeat Until %N1% = 16777215 Get Pixel: beneath the mouse into %N1% End Repeat Mouse Left Button Click Delay 100 Milliseconds // // Third click Mouse Move Windows 783, 651 // Where to click 3 Repeat Until %N1% = 215 Get Pixel: beneath the mouse into %N1% Repeat End Mouse Left Button Click Delay 100 Milliseconds I am not convinced that the delays are needed, so try removing them once the macro is working.
  3. I think it's possible. This worked with a specific Word file: Get Control: (WINWORD.EXE) -> %Control% Delay: 250 milliseconds Text Type (Send Text Directly to Control %Control%): Hello World! Without the delay, the script did not work when the document was minimized. With it, no problem.
  4. You're stuck either using <ARROW RIGHT><ARROW RIGHT><ARROW RIGHT>... or wrapping a single <ARROW RIGHT> in a Repeat statement.
  5. Macro Express determines the position of the mouse pointer relative to the top left corner of the screen, window, or control. So if your mouse is hovering over the top left corner of a window, the mouse locator will report that it is at coordinates (0, 0) relative to the window.
  6. If you export your macros, and then import them into a new file, I think the index numbers get reset. I don't know of a way to manually change the index numbers.
  7. I don't use Crystal Reports either, but I am familiar with applications that reveal their status indirectly. If it's possible to infer that all fields are populated by visually inspecting the UI, then it should be possible to script a macro to watch for the condition. The two most likely ways to do this are: 1. Monitor the shape of the mouse pointer at position x, y. 2. Monitor the colour of the pixel at position x, y.
  8. Show us how you scripted the two commands. These should be straightforward in Macro Express, something like this for one: Mouse Left Click And this for the other: Mouse Left Double Click Also, try changing the hotkeys to, say, F1 and F2. This is purely a debugging move. Sometimes there are problems when assigning a modifier key + character, especially if "Wait for the Hotkey to be released before activating" is unchecked.
  9. There is no ME equivalent of the ActiveWord ActionPad, but there are ways to use ShortKeys that are quite cool. For example, if you opt to use prefix shortkeys and change the default prefix from ## to a single character such as Q or comma, you can create scripts that are activated simply by typing a "word." In many cases, it does not even matter whether you type into a document or field. I use the comma as a prefix because no "real" words start with this character. Here are examples of macros: ,x = close window ,word = open Word ,x = open Excel ,f = open firefox ,sig = insert my name and address The only time these Shortkey macros screw up is when typing into a window where backspace does something other than deleting a character to the left of the insertion point. In Windows Explorer when focus is on the list of files, or in IE when focus is in the active window, pressing backspace is the equivalent to clicking the "Back" button.
  10. There is a lot that one can accomplish with Macro Express, but occasionally, I encounter a task that it cannot handle, or that it does not handle well. I have started to use AutoHotkey in these situations. You will need to experiment to find out AutoHotkey or AutoIt will do the job. AJAX-based Web applications are relatively new, so you may have to do a lot of testing!
  11. You would need to start from scratch with AutoIt, although you may be able to "borrow" the logic from your MEP scripts. Unfortunately, MEP scripts do not run without MEP. There is no way to convert MEP scripts to exe files. The ability to convert Macro Express scripts to free standing executables is my number one feature request. Because it is not available, I started scripting with AutoHotkey for certain tasks. A couple of years ago, I made the case for an organization installing Macro Express on about 20 PCs. They embraced the idea because there was no doubt that the macros made employees more productive.
  12. Try sending <CONTROL>a or <SHIFT><END> before sending the keystrokes to the control. Either of these key sequences should select the text. Then, when you send new text to the control, it will replace the existing text. You may or may not need a short delay between the two steps.
  13. 1. Select a desktop icon. 2. Press F2 to rename. 3. Use MEP to move the mouse cursor to the text cursor position. 4. Get the coordinates relative to the screen. The coordinates of the field are not exactly the coordinates of the icon, but nudging the cursor upwards a little (or hunting for icon-specific pixel colours) should take you to the icon itself. Perhaps the position found in step 4, above, is close enough to do what the OP wants to do.
  14. The possibility of an infinite loop is an inherent problem to the "Repeat Until" logic. It is an elegant and efficient loop, but if the test condition is not met, the script must be stopped manually. MEP error trapping for "Repeat Until" cannot prevent most infinite loops: Macro Express looks for a canceled dialog box, a non-existent path, an undefined variable, and that's all. Increasingly, I add a "fail safe" mechanism when I use "Repeat Until."For example, I might do something like this to prevent infinite loops: // Check each pixel along a vertical line from (5,0) to (5, screen height) for black (pixel color = 0) // // The VARIABLES // Set %N1% = Height of screen in pixels // Screen height count. (A fail-safe so "Repeat Until" won't repeat forever) Set %N2% = -1 // Pixel Colour. (We are looking for 0, so start with a colour that does not exist) Set %N3% = 5 // X-coordinate relative to screen Set %N4% = 0 // Y-coordinate relative to screen // // The REPEAT LOOP // Repeat Until %N2% = 0 // Hunt for a black pixel Move Mouse to %N3% %N4% relative to screen // X and Y Get Pixel Color at %N3% %N4% and store in %N2% // // The FAIL-SAFE: Prevent infinite loop by checking a finite number of pixels: the screen height // If %N1% = 0 Then // The entire vertical line has been checked. The pixel was not found! Stop End if %N1% = %N1% - 1 // Decrement the screen height counter %N4% = %N4% + 1 // We will check the next Y coordinate on the next pass Repeat End // // The FINISH: The pixel was found, so do to next step
  15. I agree, but it is possible to make ME Pro less clumsy. I use a program called "Macro Express Pro" for this purpose. I have almost 40 program and window specific scripts to streamline Macro Express. I prefer ME Pro when scripts use a lot of variables. One macro I rely on needed 14 variables. It was a lot easier to debug, and is easier to maintain, with variables names like %PixelColour% and %MousePositionX% instead of %N1% and %N99%.
  16. Under "System," you will find "Get Pixel Color," which assigns a pixel colour to an integer variable. To test it, use "If Variable ..." Use the "Mouse Locator" to determine pixel colours.
  17. There are ways -- albeit indirect ways -- to infer when a Web page has loaded. It usually takes fancy scripting, and the resulting scripts are never 100% reliable. In general, I try to avoid time delays in scripts, but I find that these kinds of macros need strategic pauses to boost reliability, and as an insurance policy against the unpredictability of Web. But excellent reliability is achievable. Approaches I have used include: 1. Monitor a single pixel for a colour change. 2. Monitor a line of pixels for a colour change. 3. Monitor a rectangle of pixels for a colour change. 4. Monitor changes in the shape of a mouse pointer at a pixel, along a line, or in a region. What and where you monitor depends on a lot of factors: the browser and its version, system settings, the Web site, and more. I have not found one approach that works on all pages and under all conditions. My most elaborate script for determining when a Web page has fully loaded uses pixel searches to calculate the dimensions of the address line, and tests for a range of pixel colour changes along its height. Although the script works when I switch screen resolutions or plug in a different monitor, I would not expect it it to work on a different computer!
  18. Nice addition, rberg! I think it is possible to script this with Macro Express, but it may take work to make it reliable. And it may not work perfectly. The script might fail, for example, if certain system settings are changed. My hunch is that the dragging aspect would work best if the desktop is set to "Auto Arrange Icons." Not sure what would happen if the desktop becomes overpopulated. Sometimes, script work under certain conditions. That's OK, as long as the user understands the limits. It's not easy to develop complex macros that are 100% reliable. The "ideal" macro is reliable, robust, fast, portable, easy to use, and easy to remember. Most scripts require trade-offs.
  19. About six months ago, I made a feature request for a fast pixel colour search. I took on the challenge of scripting a macro to test every pixel within a rectangle. It works, but runs far too slow to be practical for more than a few thousand coordinates. AutoHotKey's pixel colour search is brilliant. It checks a million or more pixels in the blink of an eye.
  20. If this can be done, you may, ironically, need a less mouse-centric approach. Once you know (or determine) the name of a recently created object on the desktop... 1. Assign it to a text variable -- let's call it %target%. 2. Put focus on the desktop -- the most reliable (non-programmatic) way I know to do this is to send this sequence of keys: (You may need to add delays between the steps) Text Type <ESC> // If "Start" menu is open, close it Text Type <WIN> // Open "Start" menu Text Type <ESC> // Close "Start" menu, but leave it focused Text Type <SHIFT><TAB> // Move focus to desktop 3. "Type out" that name to give focus the new object: Text Type %target% // Incremental search for item on desktop Note that this technique can fail if there is another object that starts with the same characters. For example, if the target is called "Hello 123" and there is already something called "Hello 1234," the latter may be found instead of the former. Under most circumstances, this will not be a problem. 4. Move the mouse cursor to the target. You will need a hack to do this. Unfortunately, this will not work: Mouse Move: To the Text Cursor Position But if you begin to rename the object, the approach will work. You may need to add delays to increase reliability: Text Type <F2> // Windows keyboard command to rename an object Mouse Move: To the Text Cursor Position Text Type <ESC> // Cancel the rename operation I hope this gets you started.
  21. What you are trying to do can probably be done. I think you might have an easier time if you use Macro Express Pro, because it supports user-supplied variable names: Instead of using built-in variables %T1% and %N1%, you can give variables names like %CopiedText% and %Column1%. My guess is that you will be manipulating a lot of variables to get the results you want. Yes, please send a sample of the kind of text you want to manipulate.
  22. Then experiment with Ctrl + F6. Although you say that the names of the four files can change, are there any consistencies? For example, is there a unique word in each of the file names? And if not, could you establish a file naming convention? Assuming there is a unique word (or phrase) in each file name, this should be possible: 1. Manually open the four spreadsheets. 2. Activate the macro. The macro visits each file in turn, extracts the file name from the window title, and saves them as text variables. Then check each variable for the unique word(s) that identify the spreadsheet: If %T1% contains "expenses" Activate Window %T1% // Slight delay // Do what you want to do with this file // Maybe close it when finished? etc. End if
  23. Not sure that this will help, but there are built in keyboard shortcuts in Excel that might at least allow a brute force solution. For example, to switch between worksheets, use Ctrl + PageUp and Ctrl + PageDown. If the four spreadsheets are kept as four worksheets in the same file, you could script something like this that would always go to the leftmost worksheet: Type Text <CONTROL><PAGEUP> Type Text <CONTROL><PAGEUP> Type Text <CONTROL><PAGEUP> Type Text <CONTROL><PAGEUP> And then, to switch to the second: Type Text <CONTROL><PAGEDOWN> You can switch between different spreadsheets with Ctrl + F6 and Shift + Ctrl+ F6.
  24. Here is a code snippet for a script I wrote in ME Pro. Variables are handled differently in ME 3, and I don't know whether ME 3 supports the "if macro xxxx enabled" command. This script enables or disables a macro nicknamed "Delete Line." I don't think it would be hard to modify the script to handle several macros. The purpose of the first and last lines is to keep the topmost window focused. You may or may not need these lines. Variable Set String %TopWindow% to topmost window title If Macro "Delete Line" is enabled Macro Disable: Delete Line Text Box Display: "Delete Line" Disabled Else Macro Enable: Delete Line Text Box Display: "Delete Line" Enabled End If Delay: 1000 milliseconds Window Activate: %TopWindow%
  25. Yes. Set the "Scope" to the title of window -- "Macro Express - Macro Explorer" (or whatever it is... I don't have ME3 running now). Here is the script: Text Type <ALT>c Text Type b Assign it to the hotkey of your choice. (I use Alt + B, for what it's worth!)
×
×
  • Create New...