Jump to content
Macro Express Forums

lemming

Members
  • Posts

    140
  • Joined

  • Last visited

Everything posted by lemming

  1. Could be a timing issue. Try adding a few Delay commands between the Tabs.
  2. Is it necessary to run the Firefox stuff in tabs? If not, you can open them in separate windows, which would be easier to manipulate using Macex. You may also be able to send keyboard commands to multiple windows by using Controls. You'll need to identify the correct windows and controls first. But if it works, it'll look like you're multi-tasking.
  3. Heh, "divide and average" aka the Babylonian method. Seems tedious, but doable. Hopefully, I won't need to do square root calculations anytime soon. Note to other users - PG Macros is the easier route.
  4. Hi Joe et al., my surname is Chan, so you can call me Lee Meng or Lemming (but not Lee). That's the name convention for my side of the world. Anyway, yes, the code does seem complicated, but I had to work with the limitations of Macex. To help out other users, I've created a slightly newer version of the Bubble Sort macro which is split into three macros so that it is (slightly) easier to understand. The main macro (top level macro) is called Bubble Sort - [MAIN] v1.0.1c , and it will call Bubble Sort - Create Array v1.0.1c and Bubble Sort - Sort Routine v1.0.1c which are self-descriptive. The main macro uses the Macro Run command to call the other two. To use these group of macros, you need to import all of them into the same category (same folder). You may also need to point the Macro Run command to the correct location of Bubble Sort - Create Array v1.0.1c and Bubble Sort - Sort Routine v1.0.1c. Pls remove earlier versions of the Bubble sort macros. The performance for v1.0.1c is the same as v1.0.1b, as are its limitations. I'm already working on a faster sort routine, and will probably do a partial implementation of Merge Sort which would be more efficient than Bubble Sort. Bubble_Sort_v1.0.1c.mex
  5. He probably wants to make the cursor move smoothly from item to item, instead of Macex's "instant" jumps. Also, some programs with drop down menus don't work properly if you don't move the mouse in a "human" way. Anyway, a macro called Schmoooove already exists which should do what you need: User Submitted Macro - Schmoooove http://www.macros.com/usermacs/umschmoooove.htm
  6. If the website is public, could u provide the url, and selection you want? It sounds like you're trying to click on a box generated by javascript, intead of a HTML drop box such as the one used at the bottom of this page. Javascript boxes are harder to code for, but still doable.
  7. You can't run two macros at once, in case that is what you're trying to do. But you can easily add code to an existing macro at various points to check for the pixel color. If found, you can call another macro to run the appropriate action. Calling another macro would have the effect of pausing your first macro. Note that Macex runs pretty fast, so you may need delays to prevent it from checking the pixel too many times a second. The relevant commands are: Get Pixel Color Macro Run Macro Return Delay The Macex Help file has very good documentation and example code for these commands.
  8. When you hold down a regular key (i.e. one which is not a Shift, Ctrl, Atl or Windows key), it is actually being repeated many times a second. So your repeat code would be one way of doing it. You should also look up the Keystroke Speed command to adjust the repeat speed.
  9. I needed a quick-and-dirty Modulo calculation so I just wrote this from scratch. Here's my macro which works as a basic calculator. Modulo operation as defined in Wikipedia In computing, the modulo operation finds the remainder of division of one number by another. Given two numbers, a and n, a modulo n (abbreviated as a mod n) is the remainder, on division of a by n. To calculate: a mod n a - n (floor( a / n )) This macro has only been lightly tested, but it appears to work for me. The macro returns the same results as the Modulo function in Win XP's Calculator (Scientific view). Of course, you can also get a Modulo (Mod) function from PG Macros: http://www.pgmacros.com/math_and_science.htm But I didn't want to install PG Macros just for one function. Modulo_calc.mex
  10. Looks like you need to figure out what is really meant by "done with the last macro". This could mean a window closing, a program exiting or a status bar changing to a certain color. All these can be checked with Macex commands. The pseudo-code would be something like this: Repeat Until "last macro is done" Delay 15 seconds Repeat End
  11. I occasionally have a need to do a select all/deselect in IE. For a deselect, I just click on position 1,1 in the control called Internet Explorer_Server. That's the web content area in IE, the area below the explorer bar, toolbars, etc. Position 1,1 is the upper left-hand corner in this area, which is unlikely to contain any links. I've included a demo macro with this posting. If it doesn't work, you'll need to find out what the control is called on your PC. It could be different depending on IE version or OS version. You can do this via the Get Control Utility which is avail under the Get Control command. -Lemming. select_deselect_IE.mex
  12. Your code is a bit hard to debug. In the future, you would want to use the "copy command text" command which is available after you Select All in the scripting editor. This is more readable for other users. Another thing you could check is whether your macro is clashing with an existing word shortcut or word macro hotkey. Word has a large number of shortcut keys. In addition, your company/coworkers could have defined their own Word hotkeys. Try searching for "Print a list of shortcut keys" in Word Help.
  13. Sounds like a timing problem. The macro is prolly running too fast. Try inserting a 200ms delay between each action.
  14. Ah, now it's clear. Looks like you need to do a few calculations. Fortunately, you don't have to reinvent the wheel. The fellas at PGM have developed a whole bunch of Date and Time functions: http://www.pgmacros.com/date_and_time.htm
  15. Seems straightforward, at least with the latest version. See screencapt.
  16. LIMITATIONS: The current limitations in this macro are: 1) Does not handle quoted commas. 2) Sorts everything as text. 3) Does not handle blank records (they are just removed). 4) Comparisons are case-insensitive (can be changed in the macro). 5) Maximum text file size has been set at 10KB and the maximum number of elements (or records) has been set at 500. More details: 1) Does not handle quoted commas which are used by certain types of csv files. For example, if you have the following records - Paris,New York,Rome,"Rome,Georgia",Miami The array will be created containing these elements: Element 1 = Paris Element 2 = New York Element 3 = Rome Element 4 = "Rome, Element 5 = Georgia" Element 6 = Miami 2) Sorts everything as text. The numbers 1 to 10 would be sorted as 1,10,2,3,4,5,6,7,8,9 because they are not "seen" as integers. With a bit more coding (mainly text->integer conversion, and back again), you can make it sort integers properly. As they often say in those Math textbooks, this is left as an exercise for the reader 3) Does not handle blank records. My macro first removes any duplicate commas and CR/LFs, that is, it replaces ,, with , These are sometimes used to indicate a blank or empty record. If you need these to be included with your final sort, replace ,, with something like ,(blank), 4) You should also note that comparisons are case-insensitive, resulting in elements sorted like this: Adam,apple,Eve,garden,Satan,snake By default, the comparisons are made using the If variable > (more than) command with the "Ignore Case" option selected. If you want case-sensitive sorting, just unselect that option, and your elements would be sorted like this: Adam,Eve,Satan,apple,garden,snake 5) Text file and element limits have been set. The macro can actually address up to 999 elements, but I have set the limit to 500. Sorting more than that would be slow and may appear to hang your PC. You can up the max values, but do so at your own risk.
  17. Apologies for the hyperbolic title. I have been visiting this site: my new filing technique is unstoppable http://www.mnftiu.cc/mnftiu.cc/filing.html so I couldn't resist Anyway, I'm pleased to announce my new (AFAIK) array technique for Macex which I believe can be used for many purposes. For instance, you could use it to address variables in a loop, or just to create (virtually) unlimited variables, far more than Macex's 99 variable limit. It also opens up Macex to more complex data-manipulation such as sorting. As an example, check out the Bubble Sort routine I implemented in the Macro Express 3.x Third Party Tools forum http://pgmacros.com/community/index.php?showforum=9. My method involves creating an array within a text variable. While this has been proposed before, I believe my method is more efficient than previous implementations. My technique can retrieve any element in an array of any size by using only 6 operations, whereas the previous solutions required a number of operations proportional to the size of the array. That is, the bigger the array, the more operations needed to retrieve data. ARRAY CREATION My technique involves appending unique array element (record) markers to the start and the end of each element, in this format: Axxx~ Element ~xxxA where xxx is an integer, Axxx~ is the begin array element marker in the Text variable, and ~xxxA is the end array element marker. So for example, if we have the following records: dog,cat,bird The array would look like this: A1~dog~1AA2~cat~2AA3~bird~3A If the array is created from user input, you can just insert the markers on-the-fly for each entry. If you want to create the array using a loop, you can use a variable reference like: A%N2%~%T1%~%N2%A where N2 would be the loop counter, and T1 would be the record which will become an array element. READING FROM ARRAY To read a particular element from the array, say, no. 13: 1. Look for position of A13~ (the begin array element marker) in the Text variable. 2. Look for position of ~13A (the end array element marker) in the Text variable. 3. Calculate length of element by subtracting the position of the begin marker from the end marker. 4. Determine length of the begin array marker (i.e. length of A13~) 5. Calculate offset for the element by adding length of begin array marker to its position. 6. Copy the the specified number of characters from the array text variable, starting at the offset position. That might not sound very efficient, but note that the number of operations to retrieve any element always remains the same, whether it is the 10th element or the 500th element. WRITING TO ARRAY Say, for instance, you want to write the word "foo" to the 13th element in the array. If the array is empty, this can be accomplished in two operations: 1. Append ~13A to the word, resulting in foo~13A 2. Replace ~13A (the end array element marker) in the Text variable with foo~13A If the array is not empty, you will need to read the existing element first, which involves 6 operations described above, followed by another two operations: Assuming the 13th element contains "fighter", 1. Append ~13A to the word currently in the array, resulting in fighter~13A 2. Replace fighter~13A in the Text variable with foo~13A I hope this array technique will be useful to others. For an example of its use, refer to the Bubble Sort macro. Regards, Lemming.
  18. Bubble Sort - Text WHAT IT DOES: Implementation of the classic Bubble Sort algorithm in Macex. TO INSTALL: Download Bubble Sort - Text v1.0.1b.mex In Macro Explorer, choose File->Import->Import Macros. Choose Bubble Sort - Text and place it into the category of your choice. TO USE: No hotkey has been defined for the macro. You can either run it directly from the Macro Explorer, or you can define your own hotkey to run it. The script read records from a text file (default is C:\unsorted list.txt). It can handle either a Comma Delimited text file (every field in each record is separated by a comma) or a Basic text file (each line of the text file is considered as a single entry to be read in). HOW IT WORKS: The Bubble Sort algorithm is well known, and is often taught to programming students. Here's a good description from http://en.wikipedia.org/wiki/Bubble_sort Bubble sort, also known as exchange sort, is a simple sorting algorithm. It works by repeatedly stepping through the list to be sorted, comparing two items at a time, swapping these two items if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which means the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top (i.e. head) of the list via the swaps. In more detail, the bubble sort algorithm works as follows: 1. Compare adjacent elements. If the first is greater than the second, swap them. 2. Do this for each pair of adjacent elements, starting with the first two and ending with the last two. At this point the last element should be the greatest. 3. Repeat the steps for all elements except the last one. 4. Keep repeating for one fewer element each time, until you have no more pairs to compare. (Alternatively, keep repeating until no swaps are needed.) I had to create my own array routine to get pass Macex's 99-variable limit, and to allow for variable manipulation in a loop. In fact, the bulk of this macro deals with array handling. Details about the array are available separately in the Macro Express 3.x forum in the thread titled "My new array technique is unstoppable!" http://pgmacros.com/community/index.php?showforum=2 LIMITATIONS: The current limitations in this macro are: 1) Does not handle quoted commas. 2) Sorts everything as text. 3) Does not handle blank records (they are just removed). 4) Comparisons are case-insensitive (can be changed in the macro). 5) Maximum text file size has been set at 10KB and the maximum number of elements (or records) has been set at 500, though though the macro can address up to 999 elements. These can be changed in the macro. The limitations are discussed in more detail in another posting. REQUIREMENTS: No "advanced" methods such as "Variable Evaluation Level" or "Run Macro in Variable" are used in this macro, so it should work with Macro Express v 3.5 or later. All testing was done with version 3.5e (3.5.5.1) of Macex. I don't have access to any older versions. Your version of Macex must at least support these commands - "Get Position of Text in a Text Variable", "Variable Set String from File", and "Repeat Options->Place Counter in Variable" Submitted by: Chan Lee Meng (Lemming) http://star-techcentral.com/ email: Not provided due to excessive spam. Contact me using the forum message system instead. Bubble_Sort___Text_v1.0.1b.mex
  19. I was looking for some sort of sorting capability in Macex and there isn't. The closest thing is a macro which generates and calls a VBS script, as discussed here. So here is my implementation of the classic Bubble Sort algorithm using Macex alone (see next posting). Sure, bubble sort is considered a "n00b" algorithm, but I say a bubble sort is better than no sort at all. This is a "pure" macro - no external programs, scripts or libraries are used. I didn't even use dynamic variables! (i.e. Run Macro in Variable). I did use "Variable Evaluation Level" initially, but even that is not required now. Here some sample data files I used for testing (included with this posting). How fast is it? Here are some benchmarks conducted on my machine which has P4 2.8GHz proc and 1GB of RAM: 50 elements = less than 1 sec (too fast to measure) 100 elements = about 5 sec 200 elements = about 17 sec 500 elements = about 1 min 3 secs In any case, you can easily conduct your own benchmarking because I've included code for reporting the start and end time. bubblesort_test_files.zip
  20. I've created a new (I think) method for arrays in Macex. It uses one text variable to store the array. I'm wondering what the maximum size of a single text variable is, so that I don't crash Macex, or even my system. Anyway, the array routine is almost done and I will release it soon. -Lemming
  21. Perhaps you could try the Wait for Window Title to Lose Focus command instead of Wait for Program to Terminate. I'm guessing Macex may occasionally miss those Dos-based programs. Alternatively, you could scrap the Wait for... commands, and just insert a really long delay (2 x the maximum time required between the operations). As a fail-safe, you could add code to look for any still-running program, and either terminate the macro or delay for a while more. -Lemming
  22. Seems quite straighforward. You could use the Get Position of Text in a Text Variable command (under Set Integer Variable) to find the comma. After that you can use Modify String Variable->Copy Part Of Text to extract the names, by refering to the comma position.
  23. Not too clear what you need. Why not just code for all the possibilities in one macro, and just copy that macro to all machines?
  24. I've conducted some experiments with separate parts of the script, and have discovered the search itself is pretty fast - it usually finishes in less than a second. The slow part is actually the line reading. For every pixel in the search grid, my script will: 1. Get pixel color (an integer) 2. Convert integer to string 3. Append string to another variable (serves as an array for the line) Repeat that step thousands, or tens of thousands of times, and you can see why it is slow. For searching I just make use of Macex's "Get Position of Text in a Text Variable" command, which in effect, is a search command. Since it is built-in, it works pretty fast. The number of search pixels and size of the search grid do not seem to affect the search time - if the lines have been read first. So what I really need now is a faster way to "read" the lines in a search grid. Unfortunately, the "most unique pixels first" approach would not work fo me in this case. Lemming.
  25. Yea, as I posted earlier, you should try to limit the search area to make it faster. You could make changes to the search area listed in the script, or perhaps you could add code to resize the window which you will be searching in. Macex already has a Resize Windows command. But in most cases, you don't even have to search the entire window. A common assumption by users is that their search object can appear "anywhere" on screen, when in fact, it is almost always confined to a certain region of the screen, for instance, the top right-hand quadrant, or somewhere along the middle portion of the screen. As for pressing the button, just use Mouse Command -> Left Button Click. My script already positions the mouse cursor on the button, if it is found. Lemming
×
×
  • Create New...