Remove autohotkey and add toggle command args

This commit is contained in:
qianlifeng
2015-01-29 22:35:01 +08:00
parent 2b1e343186
commit a112c6d9ee
9 changed files with 29 additions and 92 deletions

View File

@@ -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;
}
}
}

View File

@@ -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<KeyValuePair<string, AutoHotkeyEngine>> engines = new List<KeyValuePair<string, AutoHotkeyEngine>>();
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<string, AutoHotkeyEngine>(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);
}
}
}
}

View File

@@ -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);
}
}