Button images from toolbar

Ask general questions here.
chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Button images from toolbar

Post by chrisgeorge » Tue Aug 25, 2009 11:29 am

I'm trying to get the image from a toolbar button with little success.

After quickly realising that it wasn't a property on the Ranorex.Button object/element, I thought about trying the remote invoke stuff again (like I did for the treeview). But I can't seem to cast the button objects to Ranorex.Control.

If i use .As<Ranorex.Control>() then the resulting control object is null
if I use the Ranorex.Control constructor, it throws a capability exception.

I don't want to have to just use the CaptureCompressedImage (which I assume just takes a screenshot of that image) as we will be running on multiple OS's and this will not be reliable enough.

Any ideas?

Thank

Chris
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Button images from toolbar

Post by Support Team » Tue Aug 25, 2009 12:29 pm

You can only create a Ranorex.Control adapter from an element if the element supports the corresponding "Control" capability, i.e. if the "Control" capability is listed in the "General" tab in Ranorex Spy for that element. Please read the following chapter in the Ranorex User Guide for more info:
http://www.ranorex.com/support/user-gui ... apter.html

If your application is a .NET Windows Forms app, I bet that the parent of your toolbar button element has the Control capability. You can then call InvokeRemotely on that parent element and get the icon corresponding to the button.

And right, if you use the Imaging class or the CaptureCompressedImage method, you will get a screenshot of the element.

Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: Button images from toolbar

Post by chrisgeorge » Wed Aug 26, 2009 9:38 am

Hi Alex,

So the application I'm trying to use is SqlServer management studio... and the parent of the button is either a Toolbar or Menubar, both I believe are MsoCommandBar objects, neither of which have the Control capability.

I'm assuming MsoCommandBar are Win32?? can these be cast to something that ranorex knows about to get more than just rudimentary control?
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Button images from toolbar

Post by Support Team » Wed Aug 26, 2009 2:01 pm

InvokeRemotely only works with .NET Windows Forms controls, so that's not an option for pure Win32 windows.

Currently, there is no direct way in Ranorex to get the icons from MsoCommandBar toolbar buttons. And I doubt there will be a way in the near future, since the interface for this control is not open to the public. So, the only way right now is to use screenshots (Imaging class or CaptureCompressedImage method).

Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: Button images from toolbar

Post by chrisgeorge » Thu Aug 27, 2009 8:31 am

I suspected as much, but thanks anyway :-). Our testers will have to do that manually... sigh! lol
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge