Fix a global hotkey issues in CMD, which will hang Wox on init.

This commit is contained in:
qianlifeng
2015-01-08 22:49:42 +08:00
parent 288be8dd71
commit 220ac2fa2d
15 changed files with 148 additions and 153 deletions

View File

@@ -13,7 +13,6 @@ namespace Wox.Plugin.CMD
{
public class CMD : IPlugin, ISettingProvider,IPluginI18n
{
private readonly GlobalHotkey globalHotkey = new GlobalHotkey();
private PluginInitContext context;
private bool WinRStroked;
private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator());
@@ -174,20 +173,20 @@ namespace Wox.Plugin.CMD
public void Init(PluginInitContext context)
{
this.context = context;
globalHotkey.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent;
}
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
bool API_GlobalKeyboardEvent(int keyevent, int vkcode, SpecialKeyState state)
{
if (CMDStorage.Instance.ReplaceWinR)
{
if (keyevent == KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed)
if (keyevent == (int)KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed)
{
WinRStroked = true;
OnWinRPressed();
return false;
}
if (keyevent == KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin)
if (keyevent == (int)KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin)
{
WinRStroked = false;
keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL);

View File

@@ -82,7 +82,7 @@ namespace Wox.Plugin.Folder
}
}).ToList();
if (!driverNames.Any(input.StartsWith))
if (driverNames != null && !driverNames.Any(input.StartsWith))
return results;
if (!input.EndsWith("\\"))

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -4,6 +4,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Windows;
using Wox.Infrastructure;
using Wox.Plugin.Program.ProgramSources;

View File

@@ -81,6 +81,9 @@
<None Include="Images\program.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Images\cmd.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>