bluppfisk

Capturing a window: same id on every computer?

9 posts in this topic

I want to share a macro I've made with my colleagues. Alas, the control capture only works on my computer, it results in some kind of error on my colleagues' computers. I guess this is because the parent window of the control has a different internal id on every computer. Is there any way to make this universally compatible or should I do the window capture on every computer?

Share this post


Link to post
Share on other sites

Just wondering if you couldn't you use the Get Control command instead? There you can choose the Partial title instead of Exact match.

Share this post


Link to post
Share on other sites
Just wondering if you couldn't you use the Get Control command instead? There you can choose the Partial title instead of Exact match.

 

Yeh, I actually used Get Control command. But my macro still returns an error on everybody else's computer. Also, the titles are exactly the same, but I think the internal window ids might differ.

Share this post


Link to post
Share on other sites

Got this from the help file.

Partial Match

This allows the Control variable to find a Window Title that partially matches the name defined in the control.

 

 

Does the Display Control Info show any differens between the two windows?

Share this post


Link to post
Share on other sites

I rarely have problems between different computers assuming the applications are the same. Are you using the "Get Control Using Text" method? If not you might want to try that. Also does the client happen to have multiple windows with the same title? Are the windows titles the same as on your machine? This will definitely cause a problem. Finally ME does have some problems with the way it caches control handles so if neither of these work for you we might look there.

 

Oh, wait. If you do have different windows titles you might need to modify the control which is easy enough to do at runtime.

Share this post


Link to post
Share on other sites

Controls work best when everything matches. If your colleagues have different versions of Windows or different versions of the application that you are automating then the Window Controls may not match. I haven't seen it personally but it seems possible that different Windows themes or different skins in the application could cause the controls to differ.

 

The Get Control command allows you to capture the control information as you are writing the macro. The solution may be to use the Capture Control command. This command captures the control as the macro runs thus eliminating any incompatibility between applications or versions of Windows. But, the downside, is that you need to know the X and Y coordinates of the control. Often we use controls because we do not have an easier way to determine the X and Y coordinates.

Share this post


Link to post
Share on other sites

Even on a single machine, I have several examples of macros containing "Get Control" commands that may work one time, but not another! Microsoft Access and Sql Server are 2 examples where controls may vary from one run to another.

Share this post


Link to post
Share on other sites

I've run in to this issue with many different applications (even Outlook E-mails and HP Service Desk). Checking in to it, I've found that the 2nd or 3rd Index (checking via the "Display Control Info") will either be a 1 or a 2, so sometimes it works and others it doesn't...

 

To get around this: When it errors out, I go in to the Macro and duplicated the GetControl line. I then re-capture the new/different Control in this duplicated GetControl. At this point I add in an "If NOT Control Enabled" and "End If", so the order would be:

 

Get Control C1 (1)

If NOT Control C1 Enabled

Get Control C1 (2)

End If

 

<GETCONTROL2P:01:WJVIEW.EXE:WFC.Window.8- Default Work Order005:5WFC.Window.81WFC.Window.81WFC.Window.841WFC.Window.81WFC.EDIT>

 

<IFCONTROL:06:01>

<GETCONTROL2P:01:WJVIEW.EXE:WFC.Window.8- Default Work Order005:5WFC.Window.82WFC.Window.81WFC.Window.841WFC.Window.81WFC.EDIT>

<ENDIF>

 

This is working fine for me so far...

 

-Patrick

Share this post


Link to post
Share on other sites

Patrick,

 

I like that idea. I have always done things like check the name of the computer, the OS Version or tried to get the version number of the application. This is a simple, elegant solution. Thank you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now