jarmo / RAutomation

RAutomation
MIT License
100 stars 33 forks source link

Table#rows #40

Closed leviwilson closed 11 years ago

leviwilson commented 11 years ago

Added support for Table#rows

jarmo commented 11 years ago

How to build uiadll.dll again from command line? I'm currently seeing these errors when trying to do that with msbuild and .sln:

c:\users\jarmo\documents\projects\ruby\rautomation\ext\uiadll\uiadll\stdafx.h(16): fatal error C1083: Cannot open include file: 'atlb ase.h': No such file or directory [C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation\ext\UiaDll\UiaDll\UiaDll.vcxproj]
Done Building Project "C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation\ext\UiaDll\UiaDll\UiaDll.vcxproj" (default targets) -- FAIL ED.

Done Building Project "C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation\ext\UiaDll\UiaDll.sln" (default targets) -- FAILED.

Build FAILED.

"C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation\ext\UiaDll\UiaDll.sln" (default target) (1) ->
"C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation\ext\UiaDll\UiaDll\UiaDll.vcxproj" (default target) (2) ->
(ClCompile target) ->
  c:\users\jarmo\documents\projects\ruby\rautomation\ext\uiadll\uiadll\stdafx.h(16): fatal error C1083: Cannot open include file: 'at lbase.h': No such file or directory [C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation\ext\UiaDll\UiaDll\UiaDll.vcxproj]

    0 Warning(s)
    1 Error(s)

Added some inline comments to the code too.

leviwilson commented 11 years ago

Were you able to get this to build? Opening a VS2010 command prompt and running msbuild UiaDll.sln worked for me.

leviwilson commented 11 years ago

I will try to work on this later tonight then.

jarmo commented 11 years ago

I can't build it since i'm using VS 2010 Express edition. It seems that Express edition does not include ATL, which is included by that project. Can we remove these dependencies or are they really needed?

Similar problem is located at SO http://stackoverflow.com/questions/11081917/atlbase-include-doesnt-work

leviwilson commented 11 years ago

Just remove the atlbase.h from stdafx.h and see if it compiles. I think I originally added it when I was using CComPtr<T>, but I am not using that anymore since I'm using MC++ and .NET for the automation.

jarmo commented 11 years ago

Now i'm seeing different errors:

"C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation\ext\UiaDll\UiaDll.sln" (default target) (1) ->
"C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation\ext\UiaDll\UiaDll\UiaDll.vcxproj" (default target) (2) ->
(ClCompile target) ->
  ToggleStateHelper.cpp(16): error C2065: 'CComPtr' : undeclared identifier [C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation\ext\U iaDll\UiaDll\UiaDll.vcxproj]
  ToggleStateHelper.cpp(16): error C2275: 'IToggleProvider' : illegal use of this type as an expression [C:\Users\Jarmo\Documents\Pro jects\Ruby\RAutomation\ext\UiaDll\UiaDll\UiaDll.vcxproj]
  ToggleStateHelper.cpp(16): error C2065: 'togglePattern' : undeclared identifier [C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation \ext\UiaDll\UiaDll\UiaDll.vcxproj]
  ToggleStateHelper.cpp(17): error C2065: 'togglePattern' : undeclared identifier [C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation \ext\UiaDll\UiaDll\UiaDll.vcxproj]
  ToggleStateHelper.cpp(25): error C2065: 'togglePattern' : undeclared identifier [C:\Users\Jarmo\Documents\Projects\Ruby\RAutomation \ext\UiaDll\UiaDll\UiaDll.vcxproj]
  ToggleStateHelper.cpp(25): error C2227: left of '->get_ToggleState' must point to class/struct/union/generic type [C:\Users\Jarmo\D ocuments\Projects\Ruby\RAutomation\ext\UiaDll\UiaDll\UiaDll.vcxproj]
leviwilson commented 11 years ago

Rather than using CComPtr<T> in ToggleStateHelper.cpp, change it to look like this:

BOOL ToggleStateHelper::IsSet(IUIAutomationElement* automationElement)
{
  IToggleProvider* togglePattern;
  HRESULT hr = automationElement->GetCurrentPattern(UIA_TogglePatternId, (IUnknown**)&togglePattern);

  if (FAILED(hr)) {
    printf("RA_GetIsSet: getCurrentPattern failed 0x%x\r\n");
    return FALSE;
  }

  ToggleState  RetVal ;
  hr = togglePattern->get_ToggleState(&RetVal) ;
  togglePattern->Release();
  if (FAILED(hr)) {
    printf("RA_GetIsSet: get_ToggleState failed 0x%x\r\n", hr);
    return FALSE;
  } else {
    return RetVal;
  }
}

All the CComPtr<T> does is auto-release COM pointers. It's the equivalent to just call Release() on it before the method returns.

jarmo commented 11 years ago

This did the trick! :+1: Thanks!