diff --git a/ExplorerTabUtility/ExplorerTabUtility.csproj b/ExplorerTabUtility/ExplorerTabUtility.csproj index a379b30..c595aeb 100644 --- a/ExplorerTabUtility/ExplorerTabUtility.csproj +++ b/ExplorerTabUtility/ExplorerTabUtility.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows;net48 + net7.0-windows;net481 enable true True diff --git a/ExplorerTabUtility/Helpers/Helper.cs b/ExplorerTabUtility/Helpers/Helper.cs index 10d110c..f793895 100644 --- a/ExplorerTabUtility/Helpers/Helper.cs +++ b/ExplorerTabUtility/Helpers/Helper.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.IO; using System.Threading; namespace ExplorerTabUtility.Helpers; @@ -58,4 +59,21 @@ public static TimeSpan GetElapsedTime(long startTicks) return Icon.ExtractAssociatedIcon(location); } + + public static string GetFullPath(string path) + { + // Check if the path contains environment variables + if (path.StartsWith("%") && path.EndsWith("%")) + { + // Replace environment variables with their values + path = Environment.ExpandEnvironmentVariables(path); + } + + // If it has : or \, assume it's a regular path + if (path.Contains(":") || path.Contains("\\")) return path; + + // Check if the path is a special folder + var fullPath = $"{Environment.GetEnvironmentVariable("USERPROFILE")}\\{path}"; + return Directory.Exists(fullPath) ? fullPath : path; + } } \ No newline at end of file diff --git a/ExplorerTabUtility/Hooks/UiAutomation.cs b/ExplorerTabUtility/Hooks/UiAutomation.cs index ca6c779..1943e2f 100644 --- a/ExplorerTabUtility/Hooks/UiAutomation.cs +++ b/ExplorerTabUtility/Hooks/UiAutomation.cs @@ -84,6 +84,7 @@ private void OnWindowOpened(AutomationElement element, EventId _) location = addressBar.Patterns.Value.Pattern.Value.Value; if (string.IsNullOrWhiteSpace(location)) return; } + location = Helper.GetFullPath(location); var tab = element.FindFirstChild(c => c.ByClassName("ShellTabWindowClass"));