Skip to content

Commit fb87411

Browse files
committed
Add auto switch support & Use const for dialog class name
1 parent 959e89f commit fb87411

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Flow.Launcher.Infrastructure/QuickSwitch/QuickSwitch.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System.IO;
22
using System.Runtime.InteropServices;
33
using System.Threading;
4+
using CommunityToolkit.Mvvm.DependencyInjection;
45
using Flow.Launcher.Infrastructure.Logger;
6+
using Flow.Launcher.Infrastructure.UserSettings;
57
using Interop.UIAutomationClient;
68
using NHotkey;
79
using SHDocVw;
@@ -17,6 +19,11 @@ public static class QuickSwitch
1719
{
1820
private static readonly string ClassName = nameof(QuickSwitch);
1921

22+
private static readonly Settings _settings = Ioc.Default.GetRequiredService<Settings>();
23+
24+
// The class name of a dialog window is "#32770".
25+
private const string DialogWindowClassName = "#32770";
26+
2027
private static CUIAutomation8 _automation = new CUIAutomation8Class();
2128

2229
private static InternetExplorer lastExplorerView = null;
@@ -98,8 +105,8 @@ private static bool JumpToPath(string path)
98105
var t = new Thread(() =>
99106
{
100107
// Jump after flow launcher window vanished (after JumpAction returned true)
101-
// and the dialog had been in the foreground. The class name of a dialog window is "#32770".
102-
var timeOut = !SpinWait.SpinUntil(() => GetForegroundWindowClassName() == "#32770", 1000);
108+
// and the dialog had been in the foreground.
109+
var timeOut = !SpinWait.SpinUntil(() => GetForegroundWindowClassName() == DialogWindowClassName, 1000);
103110
if (timeOut)
104111
{
105112
return;
@@ -150,10 +157,13 @@ uint dwmsEventTime
150157
return;
151158
}
152159

153-
if (window is { CurrentClassName: "#32770" })
160+
if (_settings.AutoQuickSwitch)
154161
{
155-
NavigateDialogPath();
156-
return;
162+
if (window is { CurrentClassName: DialogWindowClassName })
163+
{
164+
NavigateDialogPath();
165+
return;
166+
}
157167
}
158168

159169
ShellWindowsClass shellWindows;

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public void Save()
5353
public string SettingWindowHotkey { get; set; } = $"Ctrl+I";
5454
public string CycleHistoryUpHotkey { get; set; } = $"{KeyConstant.Alt} + Up";
5555
public string CycleHistoryDownHotkey { get; set; } = $"{KeyConstant.Alt} + Down";
56-
public string QuickSwitchHotkey { get; set; } = $"{KeyConstant.Alt} + G";
56+
public string QuickSwitchHotkey { get; set; } = $"{KeyConstant.Ctrl} + G";
57+
58+
public bool AutoQuickSwitch { get; set; } = false;
5759

5860
public string Language
5961
{

0 commit comments

Comments
 (0)