mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Add autohotkey
This commit is contained in:
BIN
References/AutoHotkey.Interop.dll
Normal file
BIN
References/AutoHotkey.Interop.dll
Normal file
Binary file not shown.
18
Wox.Infrastructure/Hotkey/AHKHotkey.cs
Normal file
18
Wox.Infrastructure/Hotkey/AHKHotkey.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
51
Wox.Infrastructure/Hotkey/AHKHotkeyEngineFactory.cs
Normal file
51
Wox.Infrastructure/Hotkey/AHKHotkeyEngineFactory.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Wox.Infrastructure/Hotkey/IHotkey.cs
Normal file
12
Wox.Infrastructure/Hotkey/IHotkey.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Wox.Infrastructure.Hotkey
|
||||||
|
{
|
||||||
|
interface IHotkey
|
||||||
|
{
|
||||||
|
bool RegisterHotkey(string hotkey, Action action);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,9 @@
|
|||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="AutoHotkey.Interop">
|
||||||
|
<HintPath>..\References\AutoHotkey.Interop.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Microsoft.VisualBasic" />
|
<Reference Include="Microsoft.VisualBasic" />
|
||||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
@@ -58,6 +61,9 @@
|
|||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Hotkey\AHKHotkey.cs" />
|
||||||
|
<Compile Include="Hotkey\AHKHotkeyEngineFactory.cs" />
|
||||||
|
<Compile Include="Hotkey\IHotkey.cs" />
|
||||||
<Compile Include="Hotkey\InterceptKeys.cs" />
|
<Compile Include="Hotkey\InterceptKeys.cs" />
|
||||||
<Compile Include="Hotkey\KeyEvent.cs" />
|
<Compile Include="Hotkey\KeyEvent.cs" />
|
||||||
<Compile Include="Logger\Log.cs" />
|
<Compile Include="Logger\Log.cs" />
|
||||||
|
|||||||
@@ -243,6 +243,9 @@ namespace Wox
|
|||||||
|
|
||||||
public void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
|
public void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
|
||||||
{
|
{
|
||||||
|
AHKHotkey ahk = new AHKHotkey();
|
||||||
|
ahk.RegisterHotkey("#R",null);
|
||||||
|
return;
|
||||||
var hotkey = new HotkeyModel(hotkeyStr);
|
var hotkey = new HotkeyModel(hotkeyStr);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -319,6 +319,7 @@ xcopy /Y /D /E $(SolutionDir)PythonHome\* $(TargetDir)PythonHome\
|
|||||||
|
|
||||||
cd "$(TargetDir)" & del /s /q *.xml
|
cd "$(TargetDir)" & del /s /q *.xml
|
||||||
|
|
||||||
|
if $(ConfigurationName) == Release (
|
||||||
cd "$(TargetDir)Plugins" & del /s /q NLog.dll
|
cd "$(TargetDir)Plugins" & del /s /q NLog.dll
|
||||||
cd "$(TargetDir)Plugins" & del /s /q NLog.config
|
cd "$(TargetDir)Plugins" & del /s /q NLog.config
|
||||||
cd "$(TargetDir)Plugins" & del /s /q Wox.Plugin.pdb
|
cd "$(TargetDir)Plugins" & del /s /q Wox.Plugin.pdb
|
||||||
@@ -330,7 +331,8 @@ cd "$(TargetDir)Plugins" & del /s /q NAppUpdate.Framework.dll
|
|||||||
cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.dll
|
cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.dll
|
||||||
cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.pdb
|
cd "$(TargetDir)Plugins" & del /s /q Wox.Infrastructure.pdb
|
||||||
cd "$(TargetDir)Plugins" & del /s /q Newtonsoft.Json.dll
|
cd "$(TargetDir)Plugins" & del /s /q Newtonsoft.Json.dll
|
||||||
cd "$(TargetDir)Plugins" & del /s /q WindowsInput.dll</PostBuildEvent>
|
cd "$(TargetDir)Plugins" & del /s /q WindowsInput.dll
|
||||||
|
)</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
Reference in New Issue
Block a user