Jump to content
Macro Express Forums

Debugging mouse-intensive macro


Recommended Posts

I have a process in Microsoft Word which has to be repeated many times. It involves eleven mouse clicks in different places. I turned on the Mouse Locator and did the process manually, recording the positions of the mouse clicks.

When I run the macro, the mouse clicks occur in different places from the ones I filled in to the 'move mouse' selection boxes, making a complete mess of things.

Is there a way of running the macro very slowly, with the mouse position shown (X and Y values) at each click, so that I can see what is going wrong? If there were, I could take notes on paper rather than trying to use the same mouse as the one that is being manipulated automatically.

Link to comment
Share on other sites

What are you trying to do with all those clicks? The reason I ask is that there are very few tasks in Microsoft Word that require pointing and clicking. I would guess that 99+% can be accomplished purely by sending a few keystrokes.

 

Macros are far more reliable when keystrokes substitute for mouse clicks.

Link to comment
Share on other sites

Ditto what Alan said. Withing limits, keystrokes have the advantage that Windows MAY buffer them so you can feed them to Word faster than it can process them, which simplifies timing (see below).

 

For testing/debugging, after each mouse move use a ME text box to display where you have moved it to, instead of having ME click the mouse. Then you can move and click the correct spot manually, so as to continue through the process and take more notes.

 

You may have to insert delays so Word can respond to a mouse click, before you continue to the next click. Often time delays will not be reliable because Windows will respond faster or slower depending what else it is doing. In cases where the screen changes you may be able to check pixel color at selected places to wait for the screen to change, so you will not be clicking the wrong screen.

Link to comment
Share on other sites

I have a delay after each click already - can they be changed en masse or do I have to change each one individually? What is an ME text box? I would have to do the mouse clicks as they open new windows or controls. As far as I know there are no keyboard alternatives to the mouse clicks - if there were I would use them. It may be that I should try this in Autohotkey, or save time by doing the job manually.

Link to comment
Share on other sites

I would use the controls feature in MEP. You can send click events to controls like a button, send text to the controls and so forth. There is a calculator tutorial in the samples macro you got with MEP.

 

But if you don't want to take the time to do controls you can still usually manipulate all controls in Windows applications with keystrokes. You can tab to the control and hit enter to depress a button or you can use the controls hotkey. Sometimes Windows hides the indicators. But in Word for instance in the Save As dialog box hit the CTRL button. Note that some of the letters are now underlines. So if I want to move to the "Save as Type" control I click CTRL+t since the "t" is underlined in the label. It's kind of a rule in Windows that you have to provide a way to do almost everything by keyboard.

 

Regarding text boxes look in your list of commands in the Script Editor and you will find one called Text Box Display.

Link to comment
Share on other sites

To allow delays to be modified add something like this to the top of your macro:

Variable Set Decimal %SmDelay% to 0.1
Variable Set Decimal %MedDelay% to 0.5
Variable Set Decimal %LgDelay% to 1.0

Then, where needed in your macro, add delay commands like this:

Delay: %MedDelay% seconds
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...