Delphi: missing interface declarations for UI Automation methods -


Such a basic question is, but I'm stuck ...

I get I'm trying to start with UI Automation using Delphi 2007 (Win32) on Windows 7. It seems that I do not have to use some methods and types. I have the .NET Framework 4.x installed on this machine, but I have imported a type of library from the C: \ Program Files (x86) \ reference assembly \ Microsoft \ Framework \ v3.0 \ UIAutomationClient.dll ... ... I am looking for UIAutomationClient_TLB:

  UIAutomationClientMajorVersion = 1; UIAutomationClientMinorVersion = 0;  

I'm not sure that this is the problem (wrong version). I can declare the following with no problem:

  var UIAuto: IUIAutomation; Element: IUIAutomationElement;  

But the methods of IUIAutomationElement are missing. For example, there is nothing in the interface declaring this method:

  IUIAutomationElement.TryGetCurrentPattern ()  

... which msdn.microsoft According to .com, there is an interface method which is returning to at least NET 3.0.

Where do I get the necessary interface announcements? Is this possibly a registration problem? If yes, then what is required to be registered, and how?

In the end, I want to play with some of the following with the UI automation, with the retrieving the text from the controls, but technically speaking, I think that you have to compile Before you get the code you can consider it a failure;)

  var UIAuto: IUIAutomation; Element: IUIAutomationElement; Rated: HRSlt; Epaton: Automationpartn; //not defined! ValuePattern: ValuePattern; //not defined! Start UIAuto: = CoUUUutomation.Create; Element: = UIAuto.GetFocusedElement (RetVal); If the specified element (element) starts then Element.TryGetCurrentPattern (ValuePattern.Pattern, APattern) does not start // if not defined! Results: = ValuePattern.Current.Value; //not defined! ...  End;  

It seems that you have imported the pure assembly.

Importing the original COM type library from the original code are the best steps:

  1. Component | Import components.
  2. Import a type library.
  3. Select UIAutomationClient which is implemented in UIAutomationCore.dll.

This imports a type of library and creates a unit called UIAutomationClient_TLB .

The method you need is the TryGetCurrentPattern method in the .net version of the interface is simply a feature method that points to failure with a Boolean return value instead of raising the exception When you call IUIAutomationElement.GetCurrentPattern , you will need to check the HRESULT return value for the failure.


Comments