Jump to content
Macro Express Forums

Capture Control Error


jimbo
 Share

Recommended Posts

I have a macro that uses the CaptureControlBeneathMouse and GetControlClass functions. Sometimes the functions return an error when the control does not exist. This is probably true as the screen repaints (without any visible trace to the user). The problem that I have is when the error is generated it aborts the macro. Is there anyway to trap an error like this and handle it rather than aborting the macro? Below is a code I am using.

 

Mouse Left Button Click

Delay 0.5 Seconds

 

// Capture Control where mouse was clicked

Capture Control to %C8%

Variable Get Control Class: %C8% to %T18%

 

Thanks,

jimbo

Link to comment
Share on other sites

You might try adding a Log Errors command at the top of the macro. With some macro commands, this causes the errors to be written to a file instead of popping up an error dialog. You could then have your macro examine the error log file to see if an error occurred. The macro may stop, however. If this is the case you may need to have a second macro examine the error log file.

Link to comment
Share on other sites

Thanks Kevin for the idea. I figured out that the error that caused the macro to abort was the GetControlClass function and not the CaptureControlBenaeathMouse function. So I setup a loop to make sure the control was visible (i.e. captured) before I tried the GetControlClass function. That appears to have worked last night as this macro takes an hour or so to run. It would still be nice to have an error trap so you could handle problems more gracefully.

 

Repeat Until %T22% = "Valid"

Capture Control to %C8%

If Control %C8% Visible

Variable Get Control Class: %C8% to %T18%

Variable Set String %T22% "Valid"

End If

Repeat End

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...