Quantcast
Channel: Mentor Graphics Communities: Message List
Viewing all articles
Browse latest Browse all 4541

Re: Close View via Automation in Xpedition

$
0
0

If the functionality you need to access a particular object is not available in the provided scripting or COM environment, you can use the UI Automation methods.

 

It's like gui.processcommand, but on steroids.  If there is an object in a window, you can find out what it's name is and then interact with it.  The processcommand stuff is useful if all you are doing is raising a dialog box and hitting the OK button, But if you need to access sub-elements, there is nothing there for that.  UI Automation gives you access to everything.

 

First caveat: I use VB.net for all my automation.  I have never tried to use UI Automation with vbscript or the Mentor Scripting tools. I have no idea if it will work at all in either of those environments.  For VB.net, you can use either the Sharp Develop IDE or Visual Studio Express.  Both are free and work equally well. I use Sharp Develop.

 

First you will need to get the UI Automation Verify software.  It's hard to get it standalone.  Microsoft used to provide it as a separate tool, but now it's bundled with the Windows SDK.  You could go that route and install the entire SDK if you want, or you can get the source code for UIAVerify from here.

 

If you have UIAVerify as part of the SDK already, skip down to "Using UIAVerify"

 

If you are using the source code I linked above, download it and unpack in the location of your choice.  Open the solution (.sln) file.  The project will open in whatever IDE you have set up.  Build the program.  Executable files will be created in the bin/Debug folder.  Run the VisualUIAVerify.exe file in there.

 

Using UIAVerify

 

When you run the UIAVerify software, the panel on the left will show you all the windows/objects/controls open on your system, starting with the Desktop at the top.  Each object has a type, like pane, window, edit, etc. The type is important, as you will see below.  See this image for an example:

 

VX_in_UIAutomation_Verify.jpg

You can see that the Xpedition window has been expanded, along with the Workspace pane, and the two workspace windows below it.  That is the information you need to interact with those windows.

 

Now you just need some code to do all this interaction.  I've attached a sample subroutine with some methods for stepping through the levels of controls and working with them.  The basic process is to get an object, then cycle through all its children to find the next level object, then repeat the process until you get to the object of interest.  Once you get the object you want, then you can interact with it in whatever ways are appropriate. You will have to do some googling to find out how to get each kind of control, and what functions are available for that control through the UI Automation interfaces.

 

I know you are new to scripting, and there are probably people who will think this is too advanced for you.  Perhaps it is.  Perhaps it's not.  Until Mentor exposes all of the objects in every window to their COM, or provides alternative methods, sometimes something like this is the only way to skin the cat. 

 

I've used the UIAutomation stuff to do many things with various Mentor tools, and have yet to suffer a nuclear holocaust as a result. For example, the contours on the outer edges of the board in the image above are created using the Grow/Shrink box in the draw object properties dialog.  I copy the board outline, then expand and trim it, then add more segments to close the loop, then turn it into a contour.  It saves a ton of time trying to follow the board edge with a contour when the board edge has a complex shape. (the grow/shrink command uses Mentor's mask engine to do all the heavy lifting.  You could also use it to do the same thing, but that would require a lot more coding effort, and an automation pro license. Using the grow/shrink box bypasses all of that in a couple of easy steps.)

 

If you run into some roadblocks, continue to post up here and we will continue to try to help you. 


Viewing all articles
Browse latest Browse all 4541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>