mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 03:37:10 +08:00
Wox now has an option to ignore hotkeys when the focused window is topmost. This will ignore not only the main Wox hotkey but also plugin hotkeys.
~ WindowIntelopHelper edited ~ User settings entry added ~ Checkbox added to General tab (as well as its events) ~ Language entries added for en/ru
This commit is contained in:
parent
92ddf2ca41
commit
7273e1218a
@ -86,6 +86,9 @@ namespace Wox.Core.UserSettings
|
||||
[JsonProperty]
|
||||
public bool RememberLastLaunchLocation { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool IgnoreHotkeysOnTopMostFocus { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ProxyServer { get; set; }
|
||||
|
||||
|
@ -10,14 +10,28 @@ namespace Wox.Helper
|
||||
public class WindowIntelopHelper
|
||||
{
|
||||
private const int GWL_STYLE = -16; //WPF's Message code for Title Bar's Style
|
||||
private const int GWL_EXSTYLE = -20; //Gets the exstyle of the window
|
||||
private const int WS_EX_TOPMOST = 0x00000008; //Topmost flag
|
||||
private const int WS_SYSMENU = 0x80000; //WPF's Message code for System Menu
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
/// <summary>
|
||||
///Checks if the foreground window is TopMost (even Wox)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool IsForegroundWindowTopMost()
|
||||
{
|
||||
return (GetWindowLong(GetForegroundWindow(), GWL_EXSTYLE) & WS_EX_TOPMOST) == WS_EX_TOPMOST;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// disable windows toolbar's control box
|
||||
/// this will also disable system menu with Alt+Space hotkey
|
||||
|
@ -23,6 +23,7 @@
|
||||
<system:String x:Key="rememberLastLocation">Remember last launch location</system:String>
|
||||
<system:String x:Key="language">Language</system:String>
|
||||
<system:String x:Key="maxShowResults">Maximum show results</system:String>
|
||||
<system:String x:Key="ignoreHotkeysIfWindowIsTopmost">Ignore hotkeys if foreground window is TopMost</system:String>
|
||||
|
||||
<!--Setting Plugin-->
|
||||
<system:String x:Key="plugin">Plugin</system:String>
|
||||
|
@ -23,6 +23,7 @@
|
||||
<system:String x:Key="rememberLastLocation">Запомнить последнее место запуска</system:String>
|
||||
<system:String x:Key="language">Язык</system:String>
|
||||
<system:String x:Key="maxShowResults">Максимальное количество результатов</system:String>
|
||||
<system:String x:Key="ignoreHotkeysIfWindowIsTopmost">Игнорировать горячие клавиши, если окно в фокусе самое верхнее</system:String>
|
||||
|
||||
<!--Setting Plugin-->
|
||||
<system:String x:Key="plugin">Плагины</system:String>
|
||||
|
@ -23,6 +23,7 @@
|
||||
<system:String x:Key="rememberLastLocation">记住上次启动位置</system:String>
|
||||
<system:String x:Key="language">语言</system:String>
|
||||
<system:String x:Key="maxShowResults">最大结果显示个数</system:String>
|
||||
<system:String x:Key="ignoreHotkeysIfWindowIsTopmost">Ignore hotkeys if foreground window is TopMost</system:String>
|
||||
|
||||
<!--设置,插件-->
|
||||
<system:String x:Key="plugin">插件</system:String>
|
||||
|
@ -23,6 +23,7 @@
|
||||
<system:String x:Key="rememberLastLocation">记住上次启动位置</system:String>
|
||||
<system:String x:Key="language">語言</system:String>
|
||||
<system:String x:Key="maxShowResults">最大結果顯示個數</system:String>
|
||||
<system:String x:Key="ignoreHotkeysIfWindowIsTopmost">Ignore hotkeys if foreground window is TopMost</system:String>
|
||||
|
||||
<!--設置,插件-->
|
||||
<system:String x:Key="plugin">插件</system:String>
|
||||
|
@ -356,6 +356,20 @@ namespace Wox
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if Wox should ignore any hotkeys
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool ShouldIgnoreHotkeys()
|
||||
{
|
||||
|
||||
if (!IsVisible
|
||||
&& UserSettingStorage.Instance.IgnoreHotkeysOnTopMostFocus
|
||||
&& WindowIntelopHelper.IsForegroundWindowTopMost())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SetCustomPluginHotkey()
|
||||
{
|
||||
if (UserSettingStorage.Instance.CustomPluginHotkeys == null) return;
|
||||
@ -364,6 +378,7 @@ namespace Wox
|
||||
CustomPluginHotkey hotkey1 = hotkey;
|
||||
SetHotkey(hotkey.Hotkey, delegate
|
||||
{
|
||||
if (ShouldIgnoreHotkeys()) return;
|
||||
ShowApp();
|
||||
ChangeQuery(hotkey1.ActionKeyword, true);
|
||||
});
|
||||
@ -372,6 +387,7 @@ namespace Wox
|
||||
|
||||
private void OnHotkey(object sender, HotkeyEventArgs e)
|
||||
{
|
||||
if (ShouldIgnoreHotkeys()) return;
|
||||
ToggleWox();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
@ -35,6 +35,9 @@
|
||||
<CheckBox x:Name="cbRememberLastLocation" Margin="10">
|
||||
<TextBlock Text="{DynamicResource rememberLastLocation}" ></TextBlock>
|
||||
</CheckBox>
|
||||
<CheckBox x:Name="cbIgnoreHotkeysIfWindowIsTopmost" Margin="10">
|
||||
<TextBlock Text="{DynamicResource ignoreHotkeysIfWindowIsTopmost}" ></TextBlock>
|
||||
</CheckBox>
|
||||
<StackPanel Margin="10" Orientation="Horizontal">
|
||||
<TextBlock Text="{DynamicResource language}"></TextBlock>
|
||||
<ComboBox Margin="10 0 0 0" Width="120" x:Name="cbLanguages" />
|
||||
|
@ -49,7 +49,6 @@ namespace Wox
|
||||
private void Setting_Loaded(object sender, RoutedEventArgs ev)
|
||||
{
|
||||
#region General
|
||||
|
||||
cbHideWhenDeactive.Checked += (o, e) =>
|
||||
{
|
||||
UserSettingStorage.Instance.HideWhenDeactive = true;
|
||||
@ -86,6 +85,20 @@ namespace Wox
|
||||
UserSettingStorage.Instance.Save();
|
||||
};
|
||||
|
||||
cbIgnoreHotkeysIfWindowIsTopmost.Checked += (o, e) =>
|
||||
{
|
||||
UserSettingStorage.Instance.IgnoreHotkeysOnTopMostFocus = true;
|
||||
UserSettingStorage.Instance.Save();
|
||||
};
|
||||
|
||||
|
||||
cbIgnoreHotkeysIfWindowIsTopmost.Unchecked += (o, e) =>
|
||||
{
|
||||
UserSettingStorage.Instance.IgnoreHotkeysOnTopMostFocus = false;
|
||||
UserSettingStorage.Instance.Save();
|
||||
};
|
||||
|
||||
|
||||
cbStartWithWindows.IsChecked = CheckApplicationIsStartupWithWindow();
|
||||
comboMaxResultsToShow.SelectionChanged += (o, e) =>
|
||||
{
|
||||
@ -97,6 +110,7 @@ namespace Wox
|
||||
cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive;
|
||||
cbDontPromptUpdateMsg.IsChecked = UserSettingStorage.Instance.DontPromptUpdateMsg;
|
||||
cbRememberLastLocation.IsChecked = UserSettingStorage.Instance.RememberLastLaunchLocation;
|
||||
cbIgnoreHotkeysIfWindowIsTopmost.IsChecked = UserSettingStorage.Instance.IgnoreHotkeysOnTopMostFocus;
|
||||
|
||||
LoadLanguages();
|
||||
comboMaxResultsToShow.ItemsSource = Enumerable.Range(2, 16);
|
||||
|
Loading…
Reference in New Issue
Block a user