Skip to content

Commit 0762987

Browse files
committed
Resolve combability with v3
1 parent d82b89a commit 0762987

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Main.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,21 @@ private class FilesTab
108108

109109
public FilesTab(AutomationElement Files)
110110
{
111-
// Find window content to reduce the scope
111+
// Find window content to reduce the scope (Files v3 and earlier)
112112
var _windowContent = Files.FindFirstChild(cf => cf.ByClassName("Microsoft.UI.Content.DesktopChildSiteBridge"));
113-
var _paneContent = _windowContent.FindFirstChild(cf => cf.ByClassName("InputSiteWindowClass"));
113+
_currentPathGet ??= _windowContent.FindFirstChild(cf => cf.ByAutomationId("CurrentPathGet"))?.AsTextBox();
114+
_currentPathSet ??= _windowContent.FindFirstChild(cf => cf.ByAutomationId("CurrentPathSet"))?.AsTextBox();
114115

116+
// Find pane content to reduce the scope (Files v4 and later)
117+
var _paneContent = _windowContent.FindFirstChild(cf => cf.ByClassName("InputSiteWindowClass"));
115118
_currentPathGet ??= _paneContent.FindFirstChild(cf => cf.ByAutomationId("CurrentPathGet"))?.AsTextBox();
119+
_currentPathSet ??= _paneContent.FindFirstChild(cf => cf.ByAutomationId("CurrentPathSet"))?.AsTextBox();
120+
121+
// Final check (in case the structure changes in future versions)
116122
if (_currentPathGet == null)
117123
{
118124
Context.API.LogError(ClassName, "Failed to find CurrentPathGet");
119125
}
120-
121-
_currentPathSet ??= _paneContent.FindFirstChild(cf => cf.ByAutomationId("CurrentPathSet"))?.AsTextBox();
122126
if (_currentPathSet == null)
123127
{
124128
Context.API.LogError(ClassName, "Failed to find CurrentPathSet");

0 commit comments

Comments
 (0)