Jump to content
Macro Express Forums

rberq

Members
  • Posts

    1,200
  • Joined

  • Last visited

  • Days Won

    61

Everything posted by rberq

  1. I'm on Windows 7 but still running ME3. No problems like you describe in that environment.
  2. Glad you got it to work, and thanks for the feedback. Note that the Repeat loop will eventually end even if the expected color doesn't appear. To be safer in a production environment, I would add a few more error-checking lines after the Repeat loop. See highlighted lines below. I didn't bother in my lottery checker macro because the prize is just a measly million dollars, so not worth getting excited about. Seriously, though, color checking can be extremely useful. I have also used it for locating a button I want to click on, when I know approximately where it is on a page but not exactly. For example, in a Repeat loop, scan down the page looking for the button color by setting a starting location then incrementing the "y" coordinate of Get Pixel each time through the loop. Don't use the Under Mouse option of Get Pixel for such a scan, because then you have to move the mouse each time through and the macro will run MUCH slower. // // Delay briefly for page to finish loading -- based on yellow "Submit" button appearing Mouse Move Screen 519, 553 Repeat Start (Repeat 3000 times) Get Pixel: Under Mouse into %N1% If Variable %N1% = 52479 Repeat Exit End If Delay 100 Milliseconds Repeat End If Variable %N1% = 52479 Else Text Box Display: Error - expected window did not appear Macro Stop End If //
  3. If Alan's idea doesn't work, pick out one or a few unique color spots on the screen you are waiting for (or just uniquely different from the screen you are starting from), then write a loop to check pixel colors in those spots until they all match. For example, the code below is checking a single location waiting for a signon screen to appear so i can check whether I have won the lottery. The macro makes it quick and easy to get my weekly bad news. Note the 100ms delay built into the loop -- one tenth of a second. You don't want the loop to run as fast as the processor will go -- the delays leave some CPU power for the browser and operating system. // // Delay briefly for page to finish loading -- based on yellow "Submit" button appearing Mouse Move Screen 519, 553 Repeat Start (Repeat 3000 times) Get Pixel: Under Mouse into %N1% If Variable %N1% = 52479 Repeat Exit End If Delay 100 Milliseconds Repeat End //
  4. Agreed. I wrote several extensive "screen scraper" applications consisting of dozens of ME3 macros. The single most crucial document involved was a Word file describing variable use as values were passed among macros. ME Pro would have made that simpler, but I think the documentation would still have been needed. Even meaningful variable names often are not fully self-describing.
  5. In the Help screens, look up Debug. IF you are testing the macro in the scripting editor, you can set a breakpoint and get a display of variable values with Debug when the break occurs. Personally, I would write a simple macro that writes messages to the log file displaying all the variables. Then you could call (Macro Run) the display macro at any point(s) you want within the macro you are debugging, and examine the results at your leisure. To see only active variables, you could do something simple like: If Variable %T1% <> "" Log Message to Default Error Log [message text T1 value is "%T1%"] End If If Variable %T2% <> "" Log Message to Default Error Log [message text T2 value is "%T2%"] End If ... If Variable %N1% <> 0 Log Message to Default Error Log [message text N1 value is "%N1%"] End If It's kind of a pain to write the variable-display macro initially, but once it is done you can use it forever, wherever you want. Example: You have written the macro Debugger_Display_Variables, so wherever you are concerned in a macro you are testing, insert Log Message to Default Error Log [message text "Debugging macro ABC at point XYZ"] Macro Run: Debugger_Display_Variables When you look in the log file you will see the message about which macro is being debugged, followed by the messages for all the individual variables.
  6. Feels great when you finally discover the problem, doesn't it? Thanks for the feedback.
  7. OK, this is a shot in the dark, but it is a situation that has caught me a couple times. Are you sure there are no trailing blanks in the T1 string? For example, if I code these commands: Variable Set String %T1% "abc " Text Box Display: ...%T1% the value of T1 is abc and three blanks, but the text box display only shows abc with no indication of the trailing blanks. In your message box, display something like this: ---%T1%--- and when it is displayed you will see ---abc --- so the trailing blanks (if any) are "visible". Another way is, in your debugging code, Variable Set Integer %N1% from Length of Variable %T1% and Include %N1% in the message box along with %T1%.
  8. One approach would be to scatter commands "Log Message to Default Error Log" at a few (or many) key spots in the macro. Start by putting them just before the "wait for" situations that you suspect. Just number the messages sequentially. Then after a failure you can review the log and see what was the last message logged and that should put you close to the problem spot. I have used log messages extensively for debugging and the macros still ran very fast. Generally I would have a "trace" switch I could turn on and off, stored in an environment variable, and the macros would bypass logging when the switch was off. For your one-time search for this problem, you don't have to get that fancy.
  9. Yes, I believe you are right, the key to using Remote Desktop is to disconnect the session without logging out. I haven't done it for a few years now, either, but I set up scheduled macros on the server that would run every hour and do file copies and cleanups. Just had to put it in the Operations Department notes that, if they rebooted the server, they had to do the remote logon and then disconnect.
  10. Variable Set String %T1% "abcdef-ghi" sample text for testing Variable Set Integer %N1% from Position of Text in Variable %T1% locate position of first hyphen within the text Variable Modify Integer: Dec (%N1%) set position back by one so hyphen won't be copied Variable Modify String: Copy Part of %T1% to %T2% copy desired text to another variable, length N1
  11. In Windows Explorer, manually place mouse over file name, click once to select the name. You could use other techniques, manual or macro-driven to do the selection. Macro can then do this: Type <ALTD>f<ALTU>m which highlights the name to be changed. Clipboard Copy the highlighted name. Set String T1 from clipboard. Variable Modify String: Lowercase %T1% Text Type T1 which overtypes the highlighted name. Text Type <ENTER>
  12. Could you do it with two macros and Notepad? That is: First macro opens Notepad and pastes the clipboard data, then exits. User modifies data (or leaves it unmodified). User starts second macro with hotkey combination. Second macro does Ctrl-a and Ctrl-c to highlight/copy contents of Notepad screen, then closes notepad and sets %T1%.
  13. Pixel colors are also handy to detect when a screen has changed. For example, you know that a certain color field will appear at a certain location when the next web page loads, so you loop repeatedly checking/waiting for it to appear. Another technique I have found handy is to move the mouse pointer down the page until the pointer style changes, say from arrow to finger, then you know it is on a link that you can click. Of course you have to know approximately where to start because a page may have many links and you don't want to click the wrong one. Or when your mouse pointer has found a link, right-click it and copy link location to clipboard, then examine it to see if it is the one you want. You have to build a delay into the mouse-move repeat loop or you can easily move over the target faster than the pointer can change.
  14. Variable Modify String [Option 2 tab] / Save to Clipboard is where that function is "hidden" in ME3. Test carefully -- I have sometimes had bad results in pasting via the clipboard. I don't know but what it is a timing issue, like Copy to Clipboard which takes an unpredictable amount of time to complete??? You can try setting the keyboard delay time which might make text typing more reliable. Generally I have found 30ms to be more than enough.
  15. It's hard to do precisely what you want in ME3, because while the repeating macro is in control, a hotkey to start the second macro will not be recognized. Here are a few approaches that might work: (1) In Macro Explorer, you can select Options / Preferances / Playback and specify an Abort Macro Hotkey combination. That can be used to abort any macro manually during execution. Then use a hotkey to start the second macro. Not ideal, but perhaps adequate.... (2) If the repeating loop can run infrequently, say once per second or less often, you could have the ME scheduler run the macro every second (or whatever interval) but remove the repeat loop -- only do the processing once each time the macro runs. In other words, the repetition will be handled by runnning the whole macro over and over, rather than by running it once. You can set up two other macros (started by hotkeys) to enable and disable the primary macro -- any time it has been enabled it will run per the scheduler, any time it has been disabled it will not run at all. The macro that does the disabling can be your second macro -- after disabling macro 1 it can continue with whatever else you want it to do. The difficulty with this approach is that the hotkey to start the disabling macro will only be recognized if it is entered between executions of the scheduled macro, so if your "repetition" macro runs once per second it may be hard to sneak in the hotkey combination at the right time. (3) You could have the primary macro end itself, by checking something during each repetition (like existence of a temporary file) that can be controlled externally independent of ME. Not as elegant but depending what you are trying to accomplish it might be satisfactory. Or convert to ME4 (ME Pro) which I think lets you start a second macro while the first is running.
  16. Don't feel bad. I once spent two days re-reading four little lines of IBM Assembler code before I finally saw my error. Once you "know" what it says, your brain automatically plugs that in for you to save time.
  17. With ME3, the short answer is No. But depending what you want to accomplish, there's probably something that can be done, maybe neatly, maybe messily. We would need more details, especially on the macro to be interrupted. For example: Do you want to interrupt the first macro temporarily and then have it continue when the second macro ends? Or do you want to simply stop the first macro when the second one runs? Is the first macro being repeated in its entirety, for example by being scheduled every second, or being called over and over again by some other macro? Or is it a REPEAT loop within the macro that runs continuously for a long time? The devil is in the details.
  18. Major puzzles like this usually have simple solutions that leave you slapping your forehead and saying "Duh!". This one has the appearance of a typing error in one of your commands, for example reading %N2% back from a registry key that doesn't exist because you mis-typed the name. Or a similar typing error in the Text Box Display command, like displaying /N2% instead of %N2%. I'm with Cory: post the actual macro code so we can help proofread it.
  19. We need something to distinguish one word (name?) from the next. Where did the list in the clipboard come from? Is there anything that separates the end of one name from the beginning of the next -- Carriage Return or New Line characters? Maybe just capitalization at the beginning of each name?
  20. Ditto what Samrae and Cory said. Sometimes you get only partial data when you highlight the whole screen, for example by using Ctrl-a. You may have to experiment as to what portion of the page to highlight and copy. You can do that experimenting manually, then paste the result to Notepad to see what is there. Once you get your macro to highlight the overall text, the trick is to parse it to determine the beginning and end of the data you want to extract. The command "Variable Set Integer [Get Position of Text in a Text Variable]" can help with the parsing.
  21. Speaking of pixel colors, I was trying to find the slider within the vertical scroll bar by looking at pixel color. I discovered that ME apparently does not see variations in color within the scroll bar. Or at least it is not seeing anything like the same color variations that my eye sees. Try it by turning on the Mouse Locator tool and see what I mean. What's that about??? (I have Windows 7 running ME3.)
  22. I generally write a repeat loop with a short delay within the loop. Delay time multiplied by number of repeats equals the (nominal) total time to wait, but if the expected color appears the wait is ended immediately. Here's a wait of zero to ten seconds. REPEAT START 100 TIMES GET PIXEL COLOR AT n1,n2 INTO n3 IF n3 = 1234567 REPEAT EXIT ELSE DELAY100ms (one tenth of a second) END IF REPEAT END * We may exit from the loop when the color is found, or after the maximum repetitions. Therefore the check below * figures out whether the color was found or not. IF n3 NOT = 1234567 TEXT BOX DISPLAY not-found message MACRO END END IF Maybe no "better" than your method, just another way of doing it. I'm not sure what you are asking for -- a way to end the wait early without killing the macro???
  23. If the problem is passing information among the macros, and variables aren't quite working, here are a couple possibilities: (1) Create registry key(s), write the data into the keys, read it back in other macros, delete the registry key when done. (2) Maybe simpler: create a temporary text file, write data into it, read back in other macros, delete when done (actually, delete only when you need to rewrite it with new data -- who cares if an itty-bitty file stays there in a temp folder?). Using files sounds slow and inefficient, but it is plenty fast enough if your macros are assisting a manual process. You won't even have time to blink while the file is written/read.
×
×
  • Create New...