bluppfisk Posted November 26, 2007 Report Share Posted November 26, 2007 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? Quote Link to comment Share on other sites More sharing options...
blopib Posted November 26, 2007 Report Share Posted November 26, 2007 Just wondering if you couldn't you use the Get Control command instead? There you can choose the Partial title instead of Exact match. Quote Link to comment Share on other sites More sharing options...
bluppfisk Posted November 26, 2007 Author Report Share Posted November 26, 2007 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. Quote Link to comment Share on other sites More sharing options...
blopib Posted November 26, 2007 Report Share Posted November 26, 2007 Got this from the help file. Partial MatchThis 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? Quote Link to comment Share on other sites More sharing options...
Cory Posted November 26, 2007 Report Share Posted November 26, 2007 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. Quote Link to comment Share on other sites More sharing options...
kevin Posted November 26, 2007 Report Share Posted November 26, 2007 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. Quote Link to comment Share on other sites More sharing options...
paul Posted November 26, 2007 Report Share Posted November 26, 2007 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. Quote Link to comment Share on other sites More sharing options...
patrickbarrett Posted December 12, 2007 Report Share Posted December 12, 2007 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 Quote Link to comment Share on other sites More sharing options...
kevin Posted December 12, 2007 Report Share Posted December 12, 2007 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.