Jump to content


Photo

Capturing a window: same id on every computer?


  • Please log in to reply
8 replies to this topic

#1 bluppfisk

bluppfisk

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 26 November 2007 - 04:57 AM

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?

#2 blopib

blopib

    Advanced

  • Members
  • PipPipPip
  • 104 posts
  • Gender:Male
  • Location:SWEDEN

Posted 26 November 2007 - 06:40 AM

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

#3 bluppfisk

bluppfisk

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 26 November 2007 - 06:44 AM

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.

#4 blopib

blopib

    Advanced

  • Members
  • PipPipPip
  • 104 posts
  • Gender:Male
  • Location:SWEDEN

Posted 26 November 2007 - 07:09 AM

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?

#5 Cory

Cory

    Master

  • Members
  • PipPipPipPipPipPipPip
  • 2,949 posts
  • Gender:Male
  • Location:Fallbrook, CA
  • Interests:Making money by helping people save money!

Posted 26 November 2007 - 10:19 AM

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.

Cory Jackson
Fallbrook, California
Bluepoint Design
Macro writer for hire! Need help with a macro fast? Just contact me.


#6 kevin

kevin

    Master

  • Admin
  • PipPipPipPipPipPipPip
  • 2,011 posts
  • Gender:Male

Posted 26 November 2007 - 10:44 AM

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.

#7 paul

paul

    Master

  • Members
  • PipPipPipPipPipPipPip
  • 1,029 posts

Posted 26 November 2007 - 04:28 PM

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

#8 PatrickB

PatrickB

    Newbie

  • Members
  • Pip
  • 21 posts

Posted 12 December 2007 - 12:26 PM

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

#9 kevin

kevin

    Master

  • Admin
  • PipPipPipPipPipPipPip
  • 2,011 posts
  • Gender:Male

Posted 12 December 2007 - 01:17 PM

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!