diff --git a/References/AutoHotkey.Interop.dll b/References/AutoHotkey.Interop.dll deleted file mode 100644 index b491cacb68..0000000000 Binary files a/References/AutoHotkey.Interop.dll and /dev/null differ diff --git a/Wox.Infrastructure/Hotkey/AHKHotkey.cs b/Wox.Infrastructure/Hotkey/AHKHotkey.cs deleted file mode 100644 index 01ade84903..0000000000 --- a/Wox.Infrastructure/Hotkey/AHKHotkey.cs +++ /dev/null @@ -1,18 +0,0 @@ -using AutoHotkey.Interop; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Infrastructure.Hotkey -{ - public class AHKHotkey : IHotkey - { - public bool RegisterHotkey(string hotkey, Action action) - { - AutoHotkeyEngine ahk = AHKHotkeyEngineFactory.CreateOrGet("default"); - ahk.ExecRaw(string.Format("{0}::MsgBox, ssss!",hotkey)); - return true; - } - } -} diff --git a/Wox.Infrastructure/Hotkey/AHKHotkeyEngineFactory.cs b/Wox.Infrastructure/Hotkey/AHKHotkeyEngineFactory.cs deleted file mode 100644 index a812489b7a..0000000000 --- a/Wox.Infrastructure/Hotkey/AHKHotkeyEngineFactory.cs +++ /dev/null @@ -1,51 +0,0 @@ -using AutoHotkey.Interop; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Infrastructure.Hotkey -{ - internal class AHKHotkeyEngineFactory - { - private static List> engines = new List>(); - - public static AutoHotkeyEngine CreateOrGet(string name) - { - AutoHotkeyEngine engine = Get(name); - if (engine == null) - { - engine = Create(name); - } - return engine; - } - - public static AutoHotkeyEngine Create(string name) - { - var ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); - engines.Add(new KeyValuePair(name, ahk)); - return ahk; - } - - public static AutoHotkeyEngine Get(string name) - { - var engine = engines.FirstOrDefault(o => o.Key == name); - if (engine.Key != null) - { - return engine.Value; - } - - return null; - } - - public static void Destroy(string name) - { - var engine = engines.FirstOrDefault(o => o.Key == name); - if (engine.Key != null) - { - engine.Value.Terminate(); - engines.Remove(engine); - } - } - } -} diff --git a/Wox.Infrastructure/Hotkey/IHotkey.cs b/Wox.Infrastructure/Hotkey/IHotkey.cs deleted file mode 100644 index 849466aa00..0000000000 --- a/Wox.Infrastructure/Hotkey/IHotkey.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Infrastructure.Hotkey -{ - interface IHotkey - { - bool RegisterHotkey(string hotkey, Action action); - } -} diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index 8d19cd7bf5..ca13df96fb 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -37,9 +37,6 @@ false - - ..\References\AutoHotkey.Interop.dll - False @@ -61,9 +58,6 @@ - - - diff --git a/Wox/CommandArgs/QueryCommandArg.cs b/Wox/CommandArgs/QueryCommandArg.cs index faecc733fb..7e58ace4e2 100644 --- a/Wox/CommandArgs/QueryCommandArg.cs +++ b/Wox/CommandArgs/QueryCommandArg.cs @@ -14,6 +14,7 @@ namespace Wox.CommandArgs public void Execute(IList args) { + Console.WriteLine("test"); if (args.Count > 0) { string query = args[0]; diff --git a/Wox/CommandArgs/ToggleCommandArg.cs b/Wox/CommandArgs/ToggleCommandArg.cs new file mode 100644 index 0000000000..743a3e8874 --- /dev/null +++ b/Wox/CommandArgs/ToggleCommandArg.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Wox.CommandArgs +{ + public class ToggleCommandArg:ICommandArg + { + public string Command + { + get { return "toggle"; } + } + + public void Execute(IList args) + { + App.Window.ToggleWox(); + } + } +} diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index b82943136e..c896f7b39f 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -243,9 +243,6 @@ namespace Wox public void SetHotkey(string hotkeyStr, EventHandler action) { - AHKHotkey ahk = new AHKHotkey(); - ahk.RegisterHotkey("#R",null); - return; var hotkey = new HotkeyModel(hotkeyStr); try { @@ -281,17 +278,21 @@ namespace Wox } private void OnHotkey(object sender, HotkeyEventArgs e) + { + ToggleWox(); + e.Handled = true; + } + + public void ToggleWox() { if (!IsVisible) { ShowWox(); - UserSettingStorage.Instance.IncreaseActivateTimes(); } else { HideWox(); } - e.Handled = true; } private void InitProgressbarAnimation() @@ -430,6 +431,7 @@ namespace Wox private void ShowWox(bool selectAll = true) { + UserSettingStorage.Instance.IncreaseActivateTimes(); if (!double.IsNaN(Left) && !double.IsNaN(Top)) { var origScreen = Screen.FromRectangle(new Rectangle((int)Left, (int)Top, (int)ActualWidth, (int)ActualHeight)); diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 11da8d8770..c6d7649a69 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -105,6 +105,7 @@ +