Jump to content
Macro Express Forums
patgenn123

Why the inconsistency with "Get Control"

Recommended Posts

I use "Get Control" to pull some information in a database field. Sometimes it works and sometimes it gives me an error that the control does not exist.

 

Why the inconsistency?

 

-P

Share this post


Link to post
Share on other sites

Hey Cory!

 

Long time no hear from! I hope all is well.

 

All I am using is this:

 

<GETCONTROL:02:ACTSAGE.EXE:004:WindowsForms10.Window.8.app.0.2004eeeACT! by Sage - Personal2008WindowsForms10.Window.8.app.0.2004eeeWindowsForms10.Window.8.app.

0.2004eeeWindowsForms10.STATIC.app.0.2004eeeContact Detail>

 

Of course, in order to see what I'm getting, I convert C2 to T2 text using <VARGETCONT:2:2> (Variable Get Control using text)

 

When I run the control, I get this:

 

<GETCONTROL2:02:ACTSAGE.EXE:WindowsForms10.Window.8.app.0.2004eeeACT! by Sage - Personal2008003:31WindowsForms10.Window.8.app.0.2004eee2WindowsForms10.Windo

w.8.app.0.2004eee1WindowsForms10.STATIC.app.0.2004eee>

 

and it tells me the control doesn't exist??? I see the last line no longer shows up when the macro is run, but why?

 

I used this a few times and it worked, but for some reason, it doesn't anymore.

 

What am I missing?

Share this post


Link to post
Share on other sites

Also,

 

That "Contact Detail" on the last line is just an inactive bar that spells out which layout a person is on. The bar is just that, a bar. It does relay to the viewer what layout he is on, but it's a secondary bar to the windows title bar with no activation characteristics as far as I can see.

 

But then why can the "Get control" pick up the text of the bar and why can the "bullseye" capture the edges of the bar/square when the bullseye lands hovers over it?

 

P

Share this post


Link to post
Share on other sites

Any inconsistency with Window Controls is a result of how a specific application defines its Window Controls, not in the way that Macro Express interfaces with them.

 

I do not have access to Act!. That makes it difficult to determine exactly what is happening. But I can repeat some general advice that applies to working with controls that may help.

 

Whether a specific area of a program is a control or not depends on how the program is written. Also, how the program is written determines whether or not the Variable Get Control Text will be able to read the text from the control. If the application you are using, in this case Act!, was written to allow a bar or edit box to respond to a request to read the text in that control, then the Variable Get Control Text command will work. Otherwise it will not.

 

When you capture the control information using the 'Get Control Utility' the 'Capture Window Control' dialog pops up. Inside this dialog you will see a check box labeled 'Get Control Using Text'. What this means is that there are two ways that Macro Express uses to identify a Window Control. One depends on the text contained in the control while the other does not. For some programs it works better to use the text method while for other programs it works better to use the non-text method.

 

If you used the text method to get the control and the program changes the text on the control, Macro Express will no longer be able to identify that control. For example, when you capture control information about the bar the text in the bar may be blank. As Act! runs it will change the text in the bar. If you checked 'Get Control Using Text' when capturing the Window Control then the Macro Express will not be able to find the control after Act! has changed the text in the control.

 

When I write macros I often insert two separate Get Control commands in my macro, one using the text method and the other the non-text method. Then I enable one and disable the other. That way I can determine which method works best for the application I am automating.

 

Some programs never change the Window Control information for a specific component. A small number of programs change the Window Control information each time the program runs. An even smaller number of programs change the Window Control information each time a specific component appears. If the program changes the control information you will need to use the Capture Control macro command instead of the Get Control macro command. The Capture Control macro command can be less convenient because it requires that the macro know the position of the control on the screen.

Share this post


Link to post
Share on other sites

Yeah, what Kevin said. I often find that the Index method works better but then again the index method has shortcomings as well so I often try one then the other. Usually between the two I get one to work.

 

And I'm doing well, thanks for asking. Just overwhelmed with troubleshooting computer issues in our modern age. VoIP phones, tape drives, routers, and firewalls... I have several cool macros to write but too many emergencies! And with QC falling in almost every sector I can't keep up with the issues from Linksys or vendors who release 2 service packs in 4 weeks that I have to deploy.... As a genius prophet once said "I can't complain but sometimes I still do" as it keeps me in the black but it does add to the "Wearing and Tearing".

Share this post


Link to post
Share on other sites

I guess that prophet is Joe Walsh?

 

Here is my frustration defined even further:

 

I can use "Get Control", use the bullseye and go to a field in the ACT! database and see that it does capture the field value.

 

Now listen: This really gets me mad!!!

 

In my macro routine, I tell my macro that i want to activate the ACT! program window BEFORE the "Get Control" line kicks in. IT DOESN"T WORK.

 

HOWEVER, if I leave Macro Express as the active window IN FRONT of an unactive ACT! program and disable the line(in Direct Editor) that activates ACT! first, then it works. The Macro program is in front of an inactive ACT! program. All I do is click the green arrow in Macro Express to run the macro (DELETING/DISABLING the line that activates the ACT! Window first) and BAM! it captures the field value in %T1%.

 

What?????????? Why does macro Express have to be in front of my main program for it to capture text from a field? I tried many different things to get it to work and nothing works except this. This is just about worthless. Why should macro express be the active window for the "Capture Control" or "Get Control" to work?

 

<DIS:<DELAY:1><DIS:<ACTIVATE2:ACT! by Sage - Personal2008><DIS:<WAITWIN2:000010:000000:ACT! by Sage - Personal2008><DIS:<MSD:500><GETCONTROL2:01:ACTSAGE.EXE:WindowsForms10.Window.8.app.0.2004eeeACT! by Sage - Personal2008008:1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.Window

.8.app.0.2004eee19WindowsForms10.Window.8.app.0.2004eee250WindowsForms10.Win

d

ow.8.app.0.2004eee1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.Wind

o

w.8.app.0.2004eee1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.EDIT.

a

pp.0.2004eee><DIS:<CAPCONTROL:F:3:1:000496,000149><DIS:<SETFOCUS:01><CCLICK:F:01:0:T:><VARGETCONT:1:1>

 

Can I get some help as to why it behaves this way. Is the macro running too fast? What is it?

 

-P

Share this post


Link to post
Share on other sites

You get a gold star for your Rocky Mountain Way(s)!

 

There is some weirdness and definite limitations with the Controls capabilities in ME. Believe me, I've found a few. I'm not sure what your problem is and I'd need to ponder it some more but there is one thing I think you might not be 'getting' about controls. Drum roll please... You do not need to activate your window to interact with the controls. In fact they can even be minimized in the system tray! If you check out the calculator tutorial there's an example someplace that shows how it can be used for calculations even though it isn't visible! It might help to reduce your complexity by taking any superfluous window activations out of there.

 

I see in your script you have already eliminated most of these lines. If it were me I would only have the enabled lines, no need for the rest.

 

C1 looks really deep. More so than most. This might be a problem. Also do you have more than one window with the same name open?

 

Now here's something I don't understand... Why do you double click on C1 then capture the text of C1. Why don't you just capture the text of C1. If you need it to change or something then I suspect you need to put a delay in.

Share this post


Link to post
Share on other sites

Cory,

 

That was the last one I tried. I just keeping on trying something to see if anything is working.. No logic behind it.

 

Nevertheless, I also "deactivated" the window activate line and it didn't work. That's the one that is making me mad!

 

I disable the line about activating ACT! and leave MACRO EXPRESS out in front of ACT!. Macro Express is the active window in front.

 

When I click the green "go" button in Macro Express, it picks up the text and writes it to %T1%. It is 100% consistent with Macro Express being the active window in front of ACT!

 

This is really maddening!

 

-P

Share this post


Link to post
Share on other sites

I think I've figured this out. It appears ACT! will allow the capturing of field data from the layout if ACT! Window Title is NOT the active window.

 

I've been looking for a way of making the window title "inactive" before the control captures the text, but I don't see a command in macro Express to make a window 'inactive". I looked in the forums and help menu, but found nothing.

 

Am I missing something? Where is this command?

 

Does this mean I have to make another program/file active and always on top?

 

Thanks!

 

-P

Share this post


Link to post
Share on other sites

That sounds really strange, there must be something else to it. But if setting focus to another window and back fixes your problem you might just do that as a temporary fix.

 

You could use the "Repeat With Windows" with a break right in the middle and a condition not to pick Act. This way you don't need to rely on some known program to be running in order to work.

 

Hmmmm.... Have you tried minimizing Act? Would that no, in effect, set the focus to another window?

Share this post


Link to post
Share on other sites
Have you tried minimizing Act? Would that no, in effect, set the focus to another window?

That was going to be my suggestion. I work with Datatel Benefactor, whose User Interface window has the same name as a hidden window, so the command Windows Activate is useless. I use Windows Minimize to minimize something else to make Benefactor the active window.

Share this post


Link to post
Share on other sites

Can I get an example of how this word work? I have never used Repeat with Windows before.

 

I just want ACT! to be unfocused for 2 seconds while the control is capturing the data. I would prefer it not be minimized.

 

Please something simple so I don't take up much of your time.

 

-P

Share this post


Link to post
Share on other sites

Kevin,

 

Is there a way to use Capture Control from a window-relative position? All i see is a screen relative x&y, mouse location or focused control. I have an application that regenerates controls on a start-up basis and thus get control will not work. I also am in an enviornment where we run duel monitors and each person their own configuration. That being said, I'd like to have consistancy when grabbing a control but not have to: a) redefine the controls each start-up or B) use mouse move/tell user to move mouse just to grab the control.

 

Any further insight would be appreciated. We have 10 seats of this software and are looking to automate some business processes globally but are running in to a few difficulties. Just trying to use the program to its full potential and maybe get a few more licenses if it works without fail. It's either that or grab one control and use TAb between fields, but I see this as problematic and downright slow.

 

Please let me know of either a viable solution or even a work-around if possible.

 

Thanks,

Brad

Share this post


Link to post
Share on other sites
Is there a way to use Capture Control from a window-relative position?
Not from within the command itself but it is pretty easy to calculate. Try this:

// Get the Top position of the window
Variable Set Integer %N1% from Top of Window
// Add to get the top of the Control
Variable Modify Integer: %N1% = %N1% + 142

// Get the Left position of the window
Variable Set Integer %N2% from Left of Window
// Add to get the left of the Control
Variable Modify Integer: %N1% = %N1% + 567

// Put %N1% and %N2% in the X: and Y: fields of the Capture Control command
Capture Control to %C1%

<REM2:Get the Top position of the window><IVAR2:01:07:><REM2:Add to get the top of the Control><NMVAR:01:01:1:0000001:2:0000142><REM2:><REM2:Get the Left position of the window><IVAR2:02:08:><REM2:Add to get the left of the Control><NMVAR:01:01:1:0000001:2:0000567><REM2:><REM2:Put %N1% and %N2% in the X: and Y: fields of the Capture Control command><CAPCONTROL:F:3:1:00%N1%,00%N2%>

Share this post


Link to post
Share on other sites

Kevin,

 

Thanks for the follow up. Pardon my ignorance, but I read the help file and kind of get it, but why are you adding numbers(142 and 567) to N1?

 

I tried your example and don't see where it's going.

 

Pat

Share this post


Link to post
Share on other sites

I should have been clearer on that point. If the control is 142 pixels down and 567 pixels to the left of the upper corner of the window then you would use these sample values. The values to use would depend on where the control is located within the window you are automating.

Share this post


Link to post
Share on other sites
Not from within the command itself but it is pretty easy to calculate. Try this:

// Get the Top position of the window
Variable Set Integer %N1% from Top of Window
// Add to get the top of the Control
Variable Modify Integer: %N1% = %N1% + 142

// Get the Left position of the window
Variable Set Integer %N2% from Left of Window
// Add to get the left of the Control
Variable Modify Integer: %N1% = %N1% + 567

// Put %N1% and %N2% in the X: and Y: fields of the Capture Control command
Capture Control to %C1%

<REM2:Get the Top position of the window><IVAR2:01:07:><REM2:Add to get the top of the Control><NMVAR:01:01:1:0000001:2:0000142><REM2:><REM2:Get the Left position of the window><IVAR2:02:08:><REM2:Add to get the left of the Control><NMVAR:01:01:1:0000001:2:0000567><REM2:><REM2:Put %N1% and %N2% in the X: and Y: fields of the Capture Control command><CAPCONTROL:F:3:1:00%N1%,00%N2%>

 

That seems to work very well. Now, it seems my only problem is that the Macro software can not locate a control in "negative space". Meaning if you have a duel monitor setup with the right window as your main screen, the left widnow is now negative to the x,y of the right monitor. (use mouse lcoator if you want to see what I mean).

 

Is this a known bug, or just a limitation?

 

Brad

Share this post


Link to post
Share on other sites

Try using the:

 

Get Control C1 (1)

If NOT Control C1 Enabled

Get Control C1 (2)

End If

 

Your current GetControl has an index list of:

 

WindowsForms10.Window.8.apps.0.2004eee

Indexes: 1 1 19 250 1 1 1 1

 

Most likely the index is changing slightly, for example:

1 1 19 250 1 1 1 1

1 2 19 250 1 1 1 1

1 3 19 250 1 1 1 1

 

You can check this be doing a GetControl every single time it errors out and checking to see if it differs slighting from your current GetControl (under "Display Control Info").

 

I'm not sure how this program changes its controls and indexes, but this an example if the second index is the one changing.

 

 

<GETCONTROL2:01:ACTSAGE.EXE:WindowsForms10.Window.8.app.0.2004eeeACT! by Sage - Personal2008008:1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.Window
.8.app.0.2004eee19WindowsForms10.Window.8.app.0.2004eee250WindowsForms10.Win
d
ow.8.app.0.2004eee1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.Wind
o
w.8.app.0.2004eee1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.EDIT.
a
pp.0.2004eee><IFCONTROL:06:01><GETCONTROL2:01:ACTSAGE.EXE:WindowsForms10.Window.8.app.0.2004eeeACT! by Sage - Personal2008008:1WindowsForms10.Window.8.app.0.2004eee2WindowsForms10.Window
.8.app.0.2004eee19WindowsForms10.Window.8.app.0.2004eee250WindowsForms10.Win
d
ow.8.app.0.2004eee1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.Wind
o
w.8.app.0.2004eee1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.EDIT.
a
pp.0.2004eee><ENDIF><IFCONTROL:06:01><GETCONTROL2:01:ACTSAGE.EXE:WindowsForms10.Window.8.app.0.2004eeeACT! by Sage - Personal2008008:1WindowsForms10.Window.8.app.0.2004eee3WindowsForms10.Window
.8.app.0.2004eee19WindowsForms10.Window.8.app.0.2004eee250WindowsForms10.Win
d
ow.8.app.0.2004eee1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.Wind
o
w.8.app.0.2004eee1WindowsForms10.Window.8.app.0.2004eee1WindowsForms10.EDIT.
a
pp.0.2004eee><ENDIF><SETFOCUS:01><VARGETCONT:1:1>

 

Note, if you find the pattern the program you are working with uses, you can just duplicate the GetControl lines (and the IF statement) and then go in to the direct editor and edit the Index that seems to be changing.

 

Hope that helps!

Share this post


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