I have a native addon which detect zoom meeting window and find some button in it.
That Native addon is made using NAPI(node-addon-api) and when I run it, it works fine...(give me that button name).

But when I try to run that native addon in electron it crash electron app.

here is native addon c++ code which detect element:

void ListDescendants(IUIAutomationElement* pParent, int indent)
{
  
  if (pParent == NULL)
      return;

  IUIAutomationTreeWalker* pControlWalker = NULL;
  IUIAutomationElement* pNode = NULL;
  
  
  g_pAutomation->get_ControlViewWalker(&pControlWalker);
  if (pControlWalker == NULL)
      goto cleanup;

  
  pControlWalker->GetFirstChildElement(pParent, &pNode);
  if (pNode == NULL)
      goto cleanup;
  
  while (pNode)
  {
      BSTR sName;
      pNode->get_CurrentName(&sName);
      //std::wcout << sName << L"\n";
      std::wstring strName(sName, SysStringLen(sName));
      if (strName.find(L"currently unmuted") != std::string::npos)
      {
        std::cout<<"####### UNMUTE"<<"\n";
      }else if(strName.find(L"currently muted") != std::string::npos){
        std::cout<<"####### MUTE"<<"\n";
      }
      SysFreeString(sName);

      ListDescendants(pNode, indent+1);
      IUIAutomationElement* pNext;
      pControlWalker->GetNextSiblingElement(pNode, &pNext);
      pNode->Release();
      pNode = pNext;
  }
cleanup:
  if (pControlWalker != NULL)
      pControlWalker->Release();

  if (pNode != NULL)
      pNode->Release();

  return;
}
0

There are 0 best solutions below