Jump to content
Macro Express Forums

Having problems with "If control / End if" statement


Recommended Posts

Hello all,

 

New to the forum but have been using Macro Express for a while. Never encountered a logic issue before and I just wanted to be sure Im entering the commands right. For some reason my macro continues regardless of If/End if statement.

 

Here is what I have so far:

 

Activate window: window name

Get control %C1% (window control syntax)

Wait for control %C1% to be come visible

 

<all of the above works fine, but I need it to end there if the control does not become visible>

 

<these commands should stop the macro if the control above is not visible, correct?>

If not control %C1% visible

End if

 

<then if the control is visible, i want the following to run>

Mouse double left click on control %C1%

Delay 3 secs

Macro Run: macro name

 

any suggestions?

Link to post
Share on other sites

Maybe this:

If not control %C1% visible
 Macro Stop
End if

or this:

If control %C1% visible
 Mouse double left click on control %C1%
 Delay 3 secs
 Macro Run: macro name
End if

But, I think if the control never becomes visible that this command:

Wait for control %C1% to be come visible

would fail and halt the macro.

 

Keep in mind that sometimes (often?) controls behave weirdly. You may not be able to see a control but it may be visible to Windows (and consequently to Macro Express). You have to test your application and adjust your macros accordingly.

Link to post
Share on other sites

Yea I think you are right about the quirks of the controls that Windows sees. I was able to create a workaround by inserting a wait for <window title> to appear before continuing...that did the trick. Now my next challenge:

 

Which commands would I need to use to capture text from a field on a form and then have a specific macro run based on the text from that field? Im almost there, but cant quite figure out the combination. I know I will have to use the If Variable and assign the text to a T variable of some sort but from there I have no clue.

Link to post
Share on other sites

Which commands would I need to use to capture text from a field on a form and then have a specific macro run based on the text from that field?

When asking a new question it is better to start a new topic.

 

I can think of two ways to get text from a field on a form. If you are able to use a control you could use the Variable Get Control Text command. If controls won't work then you need to use the clipboard. Highlight the text and Text Type <CTRL>c to copy. Then use the Variable Set String from Clipboard. Once the information is in a variable you can use the If Variable command to have your macro do different things.

Link to post
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...
×
×
  • Create New...