投稿者 魔界の仮面弁士  (社会人) 投稿日時 2022/12/22 20:26:18
> uiInvoke.Invoke 
> のところで、[設定アプリ]が、一瞬光って、反応しているのです

VB6 が無いので VB.NET で試してみましたが、同じ状況ですね…。

Dim GetChild As Func(Of AutomationElement, AutomationProperty, String, AutomationElement) =
    Function(u, p, s) u.FindFirst(TreeScope.Children, New PropertyCondition(p, s))
Dim GetChildren As Func(Of AutomationElement, AutomationProperty, String, AutomationElementCollection) =
    Function(u, p, s) u.FindAll(TreeScope.Children, New PropertyCondition(p, s))

Dim proc = Process.GetProcesses().FirstOrDefault(Function(x) x.MainWindowTitle = "設定")
Dim uiElm = AutomationElement.FromHandle(proc.MainWindowHandle)
Dim uiCoreWindow = GetChild(uiElm, AutomationElement.ClassNameProperty, "Windows.UI.Core.CoreWindow")
Dim uiLandmarkTarget = GetChildren(uiCoreWindow, AutomationElement.ClassNameProperty, "LandmarkTarget")(1)
Dim uiViewer = GetChild(uiLandmarkTarget, AutomationElement.AutomationIdProperty, "ItemsControlScrollViewer")
Dim uiGroup = GetChild(uiViewer, AutomationElement.ClassNameProperty, "GroupItem")
Dim uiButton = GetChild(uiGroup, AutomationElement.AutomationIdProperty, "SystemSettings_DefaultApps_Browser_Button")

DirectCast(uiButton.GetCurrentPattern(ScrollItemPatternIdentifiers.Pattern), ScrollItemPattern).ScrollIntoView()
DirectCast(uiButton.GetCurrentPattern(InvokePattern.Pattern), InvokePattern).Invoke()



> マウスオーバーとかマウスクリックを具体的に
> 指示できませんでしょうか。

そちらは SendInput API で。

http://nonsoft.la.coocan.jp/SoftSample/VB.NET/SampleSendInput.html
https://liclog.net/mouse_event-function-vba-api/