Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 10相当于LaunchAdvancedAssociationUI_Windows_Winapi_Windows 10_Windows Shell_Controlpanel - Fatal编程技术网

Windows 10相当于LaunchAdvancedAssociationUI

Windows 10相当于LaunchAdvancedAssociationUI,windows,winapi,windows-10,windows-shell,controlpanel,Windows,Winapi,Windows 10,Windows Shell,Controlpanel,自Windows 10以来,该功能不再工作 在Windows Vista 7和8上,它会打开指定应用程序的“设置程序关联”页面上的控制面板 在Windows10上,它什么也不做 甚至在Microsoft文档中也有记录: 从Windows 10开始,这不会启动关联对话框。它向用户显示一个对话框,通知他们可以更改用于在其设置中打开文件扩展名的默认程序 (即使在当前版本的Windows 10中,该语句的第二部分也不再正确) 实际上,在Windows10的最新版本中,控制面板已经不存在了。其功能已移动

自Windows 10以来,该功能不再工作

在Windows Vista 7和8上,它会打开指定应用程序的“设置程序关联”页面上的控制面板

在Windows10上,它什么也不做

甚至在Microsoft文档中也有记录:

从Windows 10开始,这不会启动关联对话框。它向用户显示一个对话框,通知他们可以更改用于在其设置中打开文件扩展名的默认程序

(即使在当前版本的Windows 10中,该语句的第二部分也不再正确)


实际上,在Windows10的最新版本中,控制面板已经不存在了。其功能已移动到设置应用程序,位于应用程序>默认应用程序>应用程序设置默认值>[应用程序名称]下

是否有方法以编程方式在Windows 10设置应用程序中打开我的应用程序的“按应用程序设置默认值”屏幕


或者,是否建议应用程序使用其他方法允许其用户在Windows 10中自定义关联?

不再允许更改系统默认应用程序。以下是网站上的公告:

更改Windows 10处理默认应用程序的方式:“默认应用程序”指Windows将文件类型和协议(如HTTP)映射到默认打开的Windows应用程序的方式。例如,您最喜爱的照片编辑器可能被设置为.JPG文件的默认应用程序,这意味着当您在文件资源管理器中双击.JPG文件时,它将在该照片编辑器中打开。在Windows 8.1中,经典Windows应用程序(Win32)可能会调用提示,要求您更改默认设置,因此您可能在安装期间和启动后看到多个提示。但是,Windows应用商店应用程序无法调用此提示。相反,在安装应用程序后,会出现一个通知横幅,通知您有新的应用程序可用,您可以单击此横幅更改默认设置

我们知道你的违约对你很重要。在Windows 10中,所有应用程序(包括经典Windows应用程序和通用Windows应用程序)将无法调用提示来更改默认值,只有Windows。您可以完全控制默认体验,同时减少多个提示可能带来的一些不必要的噪音

即使有办法启动“设置”应用程序,您也无法执行更多操作。

要打开“设置默认程序”页面,请执行以下操作:

%windir%\system32\control.exe/name Microsoft.DefaultPrograms/page pageDefaultProgram
参考:

注意:此方法不适用于2018年4月的更新。


要打开“按文件类型选择默认应用”页面,请执行以下操作:


1709版或更高版本

要打开“按应用设置默认值”页面,请执行以下操作:

  • 打开控制面板中的主默认程序窗口:

    %windir%\system32\control.exe/name Microsoft.DefaultPrograms

  • 打开设置默认程序页面:

    %windir%\system32\control.exe/name Microsoft.DefaultPrograms/page pageDefaultProgram

  • 打开设置程序关联的页面:

    %windir%\system32\control.exe/name Microsoft.DefaultPrograms/page pageDefaultProgram\pageAdvancedSettings?pszAppName=YourAppRegName

    YourAppRegName是您在HKEY\U LOCAL\U机器上注册的应用程序的名称(或HKEY\U当前用户)\SOFTWARE\RegisteredApplication,在使用前必须转义(使用,Luke!)。例如:

    %windir%\system32\control.exe/name Microsoft.DefaultPrograms/page pageDefaultProgram\pageAdvancedSettings?pszAppName=Internet%20Explorer

  • 打开将文件类型或协议与程序关联页面:

    %windir%\system32\control.exe/name Microsoft.DefaultPrograms/page pageFileAssoc

  • 打开更改自动播放设置页面:

    %windir%\system32\control.exe/name Microsoft.AutoPlay

  • 打开设置程序访问和计算机默认值页面:

    %windir%\system32\ComputerDefaults.exe

另外,您也可以使用方法打开控制面板项/页:

IOpenControlPanel*OpenControlPanel;
HRESULT结果=
CoCreateInstance(CLSID_OpenControlPanel,
NULL,CLSCTX_INPROC,uuuIdof(IOpenControlPanel),(void**)和OpenControlPanel);
如果(成功(结果))
{
const wchar_t*Page=L“pageDefaultProgram\\pageAdvancedSettings?pszAppName=YourAppRegName”;
OpenControlPanel->Open(L“Microsoft.DefaultPrograms”,第页,空);
打开控制面板->释放();
}
我成功地使用了。这不是理想的解决方案,但似乎有效。以下是内联注释的代码:

#include <stdio.h>
#include <windows.h>
#include <atlbase.h>
#include <atlcom.h>
#include <UIAutomationCore.h>
#include <UIAutomationClient.h>

// the main function
HRESULT OpenSetDefaultsByApp(LPCWSTR appName);

// helpers
HRESULT FindFirstChild(IUIAutomation *automation, IUIAutomationElement *element, PROPERTYID pid, VARIANT value, IUIAutomationElement **child);
HRESULT FindFirstChildInList(IUIAutomation *automation, IUIAutomationElement *list, PROPERTYID pid, VARIANT value, IUIAutomationElement **child);
HRESULT OpenSetDefaultsByApp();

// some useful macros for error handling
// uses wprintf so you might want to change it, if running in a non-console context
#define WIDEN2(x) L ## x
#define WIDEN(x) WIDEN2(x)
#define __WFILE__ WIDEN(__FILE__)
#define HRCHECK(__expr) {hr=(__expr);if(FAILED(hr)){wprintf(L"FAILURE 0x%08X (%i)\n\tline: %u file: '%s'\n\texpr: '" WIDEN(#__expr) L"'\n",hr, hr, __LINE__,__WFILE__);goto cleanup;}}

int main()
{
  CoInitialize(NULL);
  OpenSetDefaultsByApp(L"Google Chrome"); // pass the app name as it's displayed in app settings
  CoUninitialize();
}

HRESULT OpenSetDefaultsByApp(LPCWSTR appName)
{
  HRESULT hr = S_OK;
  CComBSTR name = appName;
  CComPtr<IUIAutomation> automation;
  CComPtr<IUIAutomationElement> root;
  CComPtr<IUIAutomationElement> settingsWindow;
  CComPtr<IUIAutomationElement> coreWindow;
  CComPtr<IUIAutomationElement> content;
  CComPtr<IUIAutomationElement> list;
  CComPtr<IUIAutomationElement> scrollViewer;
  CComPtr<IUIAutomationElement> appNameListItem;
  CComPtr<IUIAutomationElement> manageButton;
  CComPtr<IUIAutomationSelectionItemPattern> selection;
  CComPtr<IUIAutomationInvokePattern> invoke;

  // because setting windows and content are completely refreshed, we need two rounds
  // one to open the list of apps
  HRCHECK(OpenSetDefaultsByApp());

  // another one to select the app that starts now...
  // create UIA COM server and get root
  HRCHECK(automation.CoCreateInstance(CLSID_CUIAutomation8));
  HRCHECK(automation->GetRootElement(&root));

  // get hierarchy one by one. This is so it doesn't take too much time
  HRCHECK(FindFirstChild(automation, root, UIA_ClassNamePropertyId, CComVariant("ApplicationFrameWindow"), &settingsWindow));
  HRCHECK(FindFirstChild(automation, settingsWindow, UIA_ClassNamePropertyId, CComVariant("Windows.UI.Core.CoreWindow"), &coreWindow));
  HRCHECK(FindFirstChild(automation, coreWindow, UIA_AutomationIdPropertyId, CComVariant("pageContent"), &content));
  HRCHECK(FindFirstChild(automation, content, UIA_AutomationIdPropertyId, CComVariant("ItemsControlScrollViewer"), &scrollViewer));

  // now the list of app should be shown, get it
  HRCHECK(FindFirstChild(automation, scrollViewer, UIA_AutomationIdPropertyId, CComVariant("SystemSettings_DefaultApps_DefaultAppsList_ListView"), &list));

  // find the item by it's name
  // the list is virtualized so we use a helper method
  // note for some reason, the name is the name plus a space... 
  name.Append(" ");
  HRCHECK(FindFirstChildInList(automation, list, UIA_NamePropertyId, CComVariant(name), &appNameListItem));

  // we got the app item, select it so the 'Manage' button can appear
  HRCHECK(appNameListItem->GetCurrentPatternAs(UIA_SelectionItemPatternId, IID_PPV_ARGS(&selection)));
  if (!selection) HRCHECK(E_FAIL);
  HRCHECK(selection->Select());

  // get the 'Manage' button
  HRCHECK(FindFirstChild(automation, scrollViewer, UIA_ClassNamePropertyId, CComVariant("Button"), &manageButton));

  // press the 'Manage' button
  HRCHECK(manageButton->GetCurrentPatternAs(UIA_InvokePatternId, IID_PPV_ARGS(&invoke)));
  if (!invoke) HRCHECK(E_FAIL);
  HRCHECK(invoke->Invoke());

cleanup:
  return hr;
}

HRESULT OpenSetDefaultsByApp()
{
  HRESULT hr = S_OK;
  CComPtr<IUIAutomation> automation;
  CComPtr<IUIAutomationElement> root;
  CComPtr<IUIAutomationElement> settingsWindow;
  CComPtr<IUIAutomationElement> coreWindow;
  CComPtr<IUIAutomationElement> content;
  CComPtr<IUIAutomationElement> setDefaultsByAppLink;
  CComPtr<IUIAutomationInvokePattern> invoke;

  // create UIA COM server and get root
  HRCHECK(automation.CoCreateInstance(CLSID_CUIAutomation8));
  HRCHECK(automation->GetRootElement(&root));

  // show up to the deepest we can
  WinExec("control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram", SW_NORMAL);

  // find the 'Set defaults by app' link (button).
  HRCHECK(FindFirstChild(automation, root, UIA_ClassNamePropertyId, CComVariant("ApplicationFrameWindow"), &settingsWindow));
  HRCHECK(FindFirstChild(automation, settingsWindow, UIA_ClassNamePropertyId, CComVariant("Windows.UI.Core.CoreWindow"), &coreWindow));
  HRCHECK(FindFirstChild(automation, coreWindow, UIA_AutomationIdPropertyId, CComVariant("pageContent"), &content));
  HRCHECK(FindFirstChild(automation, content, UIA_AutomationIdPropertyId, CComVariant("SettingsPageAppsDefaultsDefaultAppsListView_HyperlinkButton"), &setDefaultsByAppLink));

  // yes, so press this button
  HRCHECK(setDefaultsByAppLink->GetCurrentPatternAs(UIA_InvokePatternId, IID_PPV_ARGS(&invoke)));
  if (!invoke) HRCHECK(E_FAIL);
  HRCHECK(invoke->Invoke());

cleanup:
  return hr;
}

// this method has retries with timeouts included, so it's much better than a raw call to FindFirst
HRESULT FindFirstChild(IUIAutomation *automation, IUIAutomationElement *element, PROPERTYID pid, VARIANT value, IUIAutomationElement **child)
{
  HRESULT hr = S_OK;
  int timeout = 5000; // max timeout is defined here as 5 sec. This should be ok for most machines
  int slice = 100; // time between too retries, defined as 100 ms.
  int time = 0;
  CComPtr<IUIAutomationCondition> condition;
  HRCHECK(automation->CreatePropertyCondition(pid, value, &condition));

  do
  {
    // I used SubTree here, this may not be appropriate in all context
    // for performance issues. In fact, this could be passed as a parameter...
    hr = element->FindFirst(TreeScope_Subtree, condition, child);
    if (*child) break;
    time += slice;
    if (time >= timeout) HRCHECK(E_FAIL);
    Sleep(slice);
  } while (TRUE);

cleanup:
  return hr;
}

// this helper supports virtualized list
HRESULT FindFirstChildInList(IUIAutomation *automation, IUIAutomationElement *list, PROPERTYID pid, VARIANT value, IUIAutomationElement **child)
{
  HRESULT hr = S_OK;
  CComBSTR lastName;
  int lastNameCount = 0;
  CComPtr<IUIAutomationCondition> trueCondition;
  HRCHECK(automation->CreateTrueCondition(&trueCondition));

  do
  {
    // get all children
    CComPtr<IUIAutomationElementArray> all;
    HRCHECK(list->FindAll(TreeScope_Children, trueCondition, &all));

    int count;
    HRCHECK(all->get_Length(&count));
    if (count == 0) continue; // there shouldn't be zero element, so go on scanning

    for (int i = 0; i < count; i++)
    {
      // test each element for the searched property
      CComPtr<IUIAutomationElement> element;
      HRCHECK(all->GetElement(i, &element));

      CComVariant v;
      HRCHECK(element->GetCurrentPropertyValue(pid, &v));
      if (VarCmp(&v, &value, 0) == 1)
      {
        HRCHECK(element.QueryInterface(child));
        goto cleanup;
      }
    }

    // not found in the current page/set, go to last element and scroll it into view to force list to load the next
    CComPtr<IUIAutomationElement> last;
    CComPtr<IUIAutomationScrollItemPattern> pattern;
    HRCHECK(all->GetElement(count - 1, &last));

    // check if we didn't progress (same name for 20 rounds)
    CComBSTR name;
    HRCHECK(last->get_CurrentName(&name));
    if (name == lastName)
    {
      lastNameCount++;
      if (lastNameCount > 20) HRCHECK(E_FAIL); // not found!
    }
    else
    {
      lastNameCount = 0;
    }
    lastName = name;

    HRCHECK(last->GetCurrentPatternAs(UIA_ScrollItemPatternId, IID_PPV_ARGS(&pattern)));
    if (!pattern) HRCHECK(E_FAIL);
    HRCHECK(pattern->ScrollIntoView());
  } while (TRUE);

cleanup:
  return hr;
}
#包括
#包括
#包括
#包括
#包括
#包括
//主要功能
HRESULT OpenSetDefaultsByApp(LPCWSTR appName);
//助手
HRESULT FindFirstChild(IUIAutomation*自动化,IUIAutomationeElement*元素,属性ID pid,变量值,IUIAutomationeElement**child);
HRESULT FindFirstChildInList(IUIAutomation*自动化,IUIAutomationeElement*列表,属性ID pid,变量值,IUIAutomationeElement**child);
HRESULT OpenSetDefaultsByApp();
//一些用于错误处理的有用宏
//使用wprintf,因此如果在非控制台上下文中运行,则可能需要对其进行更改
#定义宽度2(x)L##x
#定义加宽(x)加宽2(x)
#定义文件加宽(文件加宽)
#定义HRCHECK(uu expr){hr=(u expr);if(FAILED(hr)){wprintf(L)失败0x%08X(%i)\n\t行:%u文件:'%s'\n\texpr:'“加宽(#uu expr)L'\n',hr,hr,u行uu,u文件u文件u);转到清理;}
int main()
{
共初始化(空);
OpenSetDefaultsByApp(L“Google Chrome”);//按应用程序设置中显示的方式传递应用程序名称
协商初始化
Activator->ActivateApplication(
    L"windows.immersivecontrolpanel_cw5n1h2txyewy"
    L"!microsoft.windows.immersivecontrolpanel",
    L"page=SettingsPageAppsDefaults"
    L"&target=SettingsPageAppsDefaultsDefaultAppsListView", AO_NONE, &pid);
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=Internet%20Explorer"
' Give Default Programs time to load
WScript.Sleep 1200
' WshShell.AppActivate "Set Program Associations to IE then end for Windows 10 enjoy! ~ The Dogs Trust Rich ~"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
msgbox "Internet Explorer is now your default browser"
WScript.Quit
#include <stdio.h>
#include <windows.h>
#include <atlbase.h>
#include <atlcom.h>
#include <UIAutomationCore.h>
#include <UIAutomationClient.h>

// the main function
HRESULT OpenSetDefaultsByApp(LPCWSTR appName);

// helpers
HRESULT FindFirstChild(IUIAutomation *automation, IUIAutomationElement *element, PROPERTYID pid, VARIANT value, IUIAutomationElement **child);
HRESULT FindFirstChildInList(IUIAutomation *automation, IUIAutomationElement *list, PROPERTYID pid, VARIANT value, IUIAutomationElement **child);
HRESULT OpenSetDefaultsByApp();

// some useful macros for error handling
// uses wprintf so you might want to change it, if running in a non-console context
#define WIDEN2(x) L ## x
#define WIDEN(x) WIDEN2(x)
#define __WFILE__ WIDEN(__FILE__)
#define HRCHECK(__expr) {hr=(__expr);if(FAILED(hr)){wprintf(L"FAILURE 0x%08X (%i)\n\tline: %u file: '%s'\n\texpr: '" WIDEN(#__expr) L"'\n",hr, hr, __LINE__,__WFILE__);goto cleanup;}}

int main()
{
  CoInitialize(NULL);
  OpenSetDefaultsByApp(L"Google Chrome"); // pass the app name as it's displayed in app settings
  CoUninitialize();
}

HRESULT OpenSetDefaultsByApp(LPCWSTR appName)
{
  HRESULT hr = S_OK;
  CComBSTR name = appName;
  CComPtr<IUIAutomation> automation;
  CComPtr<IUIAutomationElement> root;
  CComPtr<IUIAutomationElement> settingsWindow;
  CComPtr<IUIAutomationElement> coreWindow;
  CComPtr<IUIAutomationElement> content;
  CComPtr<IUIAutomationElement> list;
  CComPtr<IUIAutomationElement> scrollViewer;
  CComPtr<IUIAutomationElement> appNameListItem;
  CComPtr<IUIAutomationElement> manageButton;
  CComPtr<IUIAutomationSelectionItemPattern> selection;
  CComPtr<IUIAutomationInvokePattern> invoke;

  // because setting windows and content are completely refreshed, we need two rounds
  // one to open the list of apps
  HRCHECK(OpenSetDefaultsByApp());

  // another one to select the app that starts now...
  // create UIA COM server and get root
  HRCHECK(automation.CoCreateInstance(CLSID_CUIAutomation8));
  HRCHECK(automation->GetRootElement(&root));

  // get hierarchy one by one. This is so it doesn't take too much time
  HRCHECK(FindFirstChild(automation, root, UIA_ClassNamePropertyId, CComVariant("ApplicationFrameWindow"), &settingsWindow));
  HRCHECK(FindFirstChild(automation, settingsWindow, UIA_ClassNamePropertyId, CComVariant("Windows.UI.Core.CoreWindow"), &coreWindow));
  HRCHECK(FindFirstChild(automation, coreWindow, UIA_AutomationIdPropertyId, CComVariant("pageContent"), &content));
  HRCHECK(FindFirstChild(automation, content, UIA_AutomationIdPropertyId, CComVariant("ItemsControlScrollViewer"), &scrollViewer));

  // now the list of app should be shown, get it
  HRCHECK(FindFirstChild(automation, scrollViewer, UIA_AutomationIdPropertyId, CComVariant("SystemSettings_DefaultApps_DefaultAppsList_ListView"), &list));

  // find the item by it's name
  // the list is virtualized so we use a helper method
  // note for some reason, the name is the name plus a space... 
  name.Append(" ");
  HRCHECK(FindFirstChildInList(automation, list, UIA_NamePropertyId, CComVariant(name), &appNameListItem));

  // we got the app item, select it so the 'Manage' button can appear
  HRCHECK(appNameListItem->GetCurrentPatternAs(UIA_SelectionItemPatternId, IID_PPV_ARGS(&selection)));
  if (!selection) HRCHECK(E_FAIL);
  HRCHECK(selection->Select());

  // get the 'Manage' button
  HRCHECK(FindFirstChild(automation, scrollViewer, UIA_ClassNamePropertyId, CComVariant("Button"), &manageButton));

  // press the 'Manage' button
  HRCHECK(manageButton->GetCurrentPatternAs(UIA_InvokePatternId, IID_PPV_ARGS(&invoke)));
  if (!invoke) HRCHECK(E_FAIL);
  HRCHECK(invoke->Invoke());

cleanup:
  return hr;
}

HRESULT OpenSetDefaultsByApp()
{
  HRESULT hr = S_OK;
  CComPtr<IUIAutomation> automation;
  CComPtr<IUIAutomationElement> root;
  CComPtr<IUIAutomationElement> settingsWindow;
  CComPtr<IUIAutomationElement> coreWindow;
  CComPtr<IUIAutomationElement> content;
  CComPtr<IUIAutomationElement> setDefaultsByAppLink;
  CComPtr<IUIAutomationInvokePattern> invoke;

  // create UIA COM server and get root
  HRCHECK(automation.CoCreateInstance(CLSID_CUIAutomation8));
  HRCHECK(automation->GetRootElement(&root));

  // show up to the deepest we can
  WinExec("control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram", SW_NORMAL);

  // find the 'Set defaults by app' link (button).
  HRCHECK(FindFirstChild(automation, root, UIA_ClassNamePropertyId, CComVariant("ApplicationFrameWindow"), &settingsWindow));
  HRCHECK(FindFirstChild(automation, settingsWindow, UIA_ClassNamePropertyId, CComVariant("Windows.UI.Core.CoreWindow"), &coreWindow));
  HRCHECK(FindFirstChild(automation, coreWindow, UIA_AutomationIdPropertyId, CComVariant("pageContent"), &content));
  HRCHECK(FindFirstChild(automation, content, UIA_AutomationIdPropertyId, CComVariant("SettingsPageAppsDefaultsDefaultAppsListView_HyperlinkButton"), &setDefaultsByAppLink));

  // yes, so press this button
  HRCHECK(setDefaultsByAppLink->GetCurrentPatternAs(UIA_InvokePatternId, IID_PPV_ARGS(&invoke)));
  if (!invoke) HRCHECK(E_FAIL);
  HRCHECK(invoke->Invoke());

cleanup:
  return hr;
}

// this method has retries with timeouts included, so it's much better than a raw call to FindFirst
HRESULT FindFirstChild(IUIAutomation *automation, IUIAutomationElement *element, PROPERTYID pid, VARIANT value, IUIAutomationElement **child)
{
  HRESULT hr = S_OK;
  int timeout = 5000; // max timeout is defined here as 5 sec. This should be ok for most machines
  int slice = 100; // time between too retries, defined as 100 ms.
  int time = 0;
  CComPtr<IUIAutomationCondition> condition;
  HRCHECK(automation->CreatePropertyCondition(pid, value, &condition));

  do
  {
    // I used SubTree here, this may not be appropriate in all context
    // for performance issues. In fact, this could be passed as a parameter...
    hr = element->FindFirst(TreeScope_Subtree, condition, child);
    if (*child) break;
    time += slice;
    if (time >= timeout) HRCHECK(E_FAIL);
    Sleep(slice);
  } while (TRUE);

cleanup:
  return hr;
}

// this helper supports virtualized list
HRESULT FindFirstChildInList(IUIAutomation *automation, IUIAutomationElement *list, PROPERTYID pid, VARIANT value, IUIAutomationElement **child)
{
  HRESULT hr = S_OK;
  CComBSTR lastName;
  int lastNameCount = 0;
  CComPtr<IUIAutomationCondition> trueCondition;
  HRCHECK(automation->CreateTrueCondition(&trueCondition));

  do
  {
    // get all children
    CComPtr<IUIAutomationElementArray> all;
    HRCHECK(list->FindAll(TreeScope_Children, trueCondition, &all));

    int count;
    HRCHECK(all->get_Length(&count));
    if (count == 0) continue; // there shouldn't be zero element, so go on scanning

    for (int i = 0; i < count; i++)
    {
      // test each element for the searched property
      CComPtr<IUIAutomationElement> element;
      HRCHECK(all->GetElement(i, &element));

      CComVariant v;
      HRCHECK(element->GetCurrentPropertyValue(pid, &v));
      if (VarCmp(&v, &value, 0) == 1)
      {
        HRCHECK(element.QueryInterface(child));
        goto cleanup;
      }
    }

    // not found in the current page/set, go to last element and scroll it into view to force list to load the next
    CComPtr<IUIAutomationElement> last;
    CComPtr<IUIAutomationScrollItemPattern> pattern;
    HRCHECK(all->GetElement(count - 1, &last));

    // check if we didn't progress (same name for 20 rounds)
    CComBSTR name;
    HRCHECK(last->get_CurrentName(&name));
    if (name == lastName)
    {
      lastNameCount++;
      if (lastNameCount > 20) HRCHECK(E_FAIL); // not found!
    }
    else
    {
      lastNameCount = 0;
    }
    lastName = name;

    HRCHECK(last->GetCurrentPatternAs(UIA_ScrollItemPatternId, IID_PPV_ARGS(&pattern)));
    if (!pattern) HRCHECK(E_FAIL);
    HRCHECK(pattern->ScrollIntoView());
  } while (TRUE);

cleanup:
  return hr;
}