mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 21:41:51 +02:00
Merge
This commit is contained in:
@@ -13,7 +13,6 @@ namespace Wox.Plugin.CMD
|
|||||||
{
|
{
|
||||||
public class CMD : IPlugin, ISettingProvider,IPluginI18n
|
public class CMD : IPlugin, ISettingProvider,IPluginI18n
|
||||||
{
|
{
|
||||||
private readonly GlobalHotkey globalHotkey = new GlobalHotkey();
|
|
||||||
private PluginInitContext context;
|
private PluginInitContext context;
|
||||||
private bool WinRStroked;
|
private bool WinRStroked;
|
||||||
private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator());
|
private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator());
|
||||||
@@ -174,20 +173,20 @@ namespace Wox.Plugin.CMD
|
|||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
this.context = 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 (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;
|
WinRStroked = true;
|
||||||
OnWinRPressed();
|
OnWinRPressed();
|
||||||
return false;
|
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;
|
WinRStroked = false;
|
||||||
keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL);
|
keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_cmd_relace_winr">替换 Win+R</system:String>
|
<system:String x:Key="wox_plugin_cmd_relace_winr">替换 Win+R</system:String>
|
||||||
<system:String x:Key="wox_plugin_cmd_leave_cmd_open">执行后不关闭命令窗口</system:String>
|
<system:String x:Key="wox_plugin_cmd_leave_cmd_open">执行后不关闭命令窗口</system:String>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -82,7 +82,7 @@ namespace Wox.Plugin.Folder
|
|||||||
}
|
}
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
if (!driverNames.Any(input.StartsWith))
|
if (driverNames != null && !driverNames.Any(input.StartsWith))
|
||||||
return results;
|
return results;
|
||||||
|
|
||||||
if (!input.EndsWith("\\"))
|
if (!input.EndsWith("\\"))
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_folder_delete">删除</system:String>
|
<system:String x:Key="wox_plugin_folder_delete">删除</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_edit">编辑</system:String>
|
<system:String x:Key="wox_plugin_folder_edit">编辑</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
|
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_folder_path">文件夹路径</system:String>
|
<system:String x:Key="wox_plugin_folder_folder_path">文件夹路径</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">请选择一个文件夹</system:String>
|
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">请选择一个文件夹</system:String>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_folder_delete">刪除</system:String>
|
<system:String x:Key="wox_plugin_folder_delete">刪除</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_edit">編輯</system:String>
|
<system:String x:Key="wox_plugin_folder_edit">編輯</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
|
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_folder_path">文件夾路徑</system:String>
|
<system:String x:Key="wox_plugin_folder_folder_path">文件夾路徑</system:String>
|
||||||
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">請選擇一個文件夾</system:String>
|
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">請選擇一個文件夾</system:String>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
BIN
Plugins/Wox.Plugin.Program/Images/cmd.png
Normal file
BIN
Plugins/Wox.Plugin.Program/Images/cmd.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Plugin.Program.ProgramSources;
|
using Wox.Plugin.Program.ProgramSources;
|
||||||
|
|||||||
@@ -81,6 +81,9 @@
|
|||||||
<None Include="Images\program.png">
|
<None Include="Images\program.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="Images\cmd.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<Content Include="Languages\en.xaml">
|
<Content Include="Languages\en.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|||||||
15
Plugins/Wox.Plugin.Sys/Languages/en.xaml
Normal file
15
Plugins/Wox.Plugin.Sys/Languages/en.xaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
|
|
||||||
|
<system:String x:Key="wox_plugin_sys_command">Command</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_desc">Description</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="wox_plugin_sys_shutdown_computer">Shutdown Computer</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_log_off">Log off</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_lock">Lock this computer</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_exit">Close Wox</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_restart">Restart Wox</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_setting">Tweak this app</system:String>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
15
Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml
Normal file
15
Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
|
|
||||||
|
<system:String x:Key="wox_plugin_sys_command">命令</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_desc">描述</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="wox_plugin_sys_shutdown_computer">关闭电脑</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_log_off">注销</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_lock">锁定这台电脑</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_exit">退出Wox</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_restart">重启Wox</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_setting">设置</system:String>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
15
Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml
Normal file
15
Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
|
|
||||||
|
<system:String x:Key="wox_plugin_sys_command">命令</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_desc">描述</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="wox_plugin_sys_shutdown_computer">關閉電腦</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_log_off">註銷</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_lock">鎖定這臺電腦</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_exit">退出Wox</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_restart">重啟Wox</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_sys_setting">設置</system:String>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Wox.Plugin.Sys
|
namespace Wox.Plugin.Sys
|
||||||
{
|
{
|
||||||
public class Sys : IPlugin, ISettingProvider
|
public class Sys : IPlugin, ISettingProvider ,IPluginI18n
|
||||||
{
|
{
|
||||||
List<Result> availableResults = new List<Result>();
|
List<Result> availableResults = new List<Result>();
|
||||||
|
private PluginInitContext context;
|
||||||
|
|
||||||
#region DllImport
|
#region DllImport
|
||||||
|
|
||||||
@@ -32,9 +35,12 @@ namespace Wox.Plugin.Sys
|
|||||||
public List<Result> Query(Query query)
|
public List<Result> Query(Query query)
|
||||||
{
|
{
|
||||||
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
|
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
|
||||||
|
if (availableResults.Count == 0)
|
||||||
|
{
|
||||||
|
LoadCommands();
|
||||||
|
}
|
||||||
|
|
||||||
List<Result> results = new List<Result>();
|
List<Result> results = new List<Result>();
|
||||||
|
|
||||||
foreach (Result availableResult in availableResults)
|
foreach (Result availableResult in availableResults)
|
||||||
{
|
{
|
||||||
if (availableResult.Title.ToLower().StartsWith(query.RawQuery.ToLower()))
|
if (availableResult.Title.ToLower().StartsWith(query.RawQuery.ToLower()))
|
||||||
@@ -47,11 +53,16 @@ namespace Wox.Plugin.Sys
|
|||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
availableResults.AddRange(new Result[] {
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadCommands()
|
||||||
|
{
|
||||||
|
availableResults.AddRange(new Result[] {
|
||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = "Shutdown",
|
Title = "Shutdown",
|
||||||
SubTitle = "Shutdown Computer",
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_shutdown_computer"),
|
||||||
Score = 100,
|
Score = 100,
|
||||||
IcoPath = "Images\\exit.png",
|
IcoPath = "Images\\exit.png",
|
||||||
Action = (c) =>
|
Action = (c) =>
|
||||||
@@ -65,7 +76,7 @@ namespace Wox.Plugin.Sys
|
|||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = "Log off",
|
Title = "Log off",
|
||||||
SubTitle = "Log off current user",
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_log_off"),
|
||||||
Score = 100,
|
Score = 100,
|
||||||
IcoPath = "Images\\logoff.png",
|
IcoPath = "Images\\logoff.png",
|
||||||
Action = (c) => ExitWindowsEx(EWX_LOGOFF, 0)
|
Action = (c) => ExitWindowsEx(EWX_LOGOFF, 0)
|
||||||
@@ -73,7 +84,7 @@ namespace Wox.Plugin.Sys
|
|||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = "Lock",
|
Title = "Lock",
|
||||||
SubTitle = "Lock this computer",
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_lock"),
|
||||||
Score = 100,
|
Score = 100,
|
||||||
IcoPath = "Images\\lock.png",
|
IcoPath = "Images\\lock.png",
|
||||||
Action = (c) =>
|
Action = (c) =>
|
||||||
@@ -85,7 +96,7 @@ namespace Wox.Plugin.Sys
|
|||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = "Exit",
|
Title = "Exit",
|
||||||
SubTitle = "Close this app",
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_exit"),
|
||||||
Score = 110,
|
Score = 110,
|
||||||
IcoPath = "Images\\app.png",
|
IcoPath = "Images\\app.png",
|
||||||
Action = (c) =>
|
Action = (c) =>
|
||||||
@@ -97,7 +108,7 @@ namespace Wox.Plugin.Sys
|
|||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = "Restart Wox",
|
Title = "Restart Wox",
|
||||||
SubTitle = "Restart Wox",
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_restart"),
|
||||||
Score = 110,
|
Score = 110,
|
||||||
IcoPath = "Images\\restart.png",
|
IcoPath = "Images\\restart.png",
|
||||||
Action = (c) =>
|
Action = (c) =>
|
||||||
@@ -115,7 +126,7 @@ namespace Wox.Plugin.Sys
|
|||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = "Settings",
|
Title = "Settings",
|
||||||
SubTitle = "Tweak this app",
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_setting"),
|
||||||
Score = 100,
|
Score = 100,
|
||||||
IcoPath = "Images\\app.png",
|
IcoPath = "Images\\app.png",
|
||||||
Action = (c) =>
|
Action = (c) =>
|
||||||
@@ -127,7 +138,10 @@ namespace Wox.Plugin.Sys
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetLanguagesFolder()
|
||||||
|
{
|
||||||
|
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
<ListView x:Name="lbxCommands" Grid.Row="0">
|
<ListView x:Name="lbxCommands" Grid.Row="0">
|
||||||
<ListView.View>
|
<ListView.View>
|
||||||
<GridView>
|
<GridView>
|
||||||
<GridViewColumn Header="Command" Width="150">
|
<GridViewColumn Header="{DynamicResource wox_plugin_sys_command}" Width="150">
|
||||||
<GridViewColumn.CellTemplate>
|
<GridViewColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Title}"/>
|
<TextBlock Text="{Binding Title}"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</GridViewColumn.CellTemplate>
|
</GridViewColumn.CellTemplate>
|
||||||
</GridViewColumn>
|
</GridViewColumn>
|
||||||
<GridViewColumn Header="Description" Width="Auto">
|
<GridViewColumn Header="{DynamicResource wox_plugin_sys_desc}" Width="Auto">
|
||||||
<GridViewColumn.CellTemplate>
|
<GridViewColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding SubTitle}"/>
|
<TextBlock Text="{Binding SubTitle}"/>
|
||||||
|
|||||||
@@ -64,6 +64,21 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Languages\en.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<None Include="Languages\zh-cn.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Languages\zh-tw.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<Page Include="SysSettings.xaml">
|
<Page Include="SysSettings.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_websearch_delete">删除</system:String>
|
<system:String x:Key="wox_plugin_websearch_delete">删除</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_edit">编辑</system:String>
|
<system:String x:Key="wox_plugin_websearch_edit">编辑</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
|
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_action_keyword">触发关键字</system:String>
|
<system:String x:Key="wox_plugin_websearch_action_keyword">触发关键字</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
|
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_enable_suggestion">启用搜索建议</system:String>
|
<system:String x:Key="wox_plugin_websearch_enable_suggestion">启用搜索建议</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">请选择一项</system:String>
|
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">请选择一项</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_delete_warning">你确定要删除 {0} 吗?</system:String>
|
<system:String x:Key="wox_plugin_websearch_delete_warning">你确定要删除 {0} 吗?</system:String>
|
||||||
|
|
||||||
|
|
||||||
<!--web search edit-->
|
<!--web search edit-->
|
||||||
<system:String x:Key="wox_plugin_websearch_title">标题</system:String>
|
<system:String x:Key="wox_plugin_websearch_title">标题</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_enable">启用</system:String>
|
<system:String x:Key="wox_plugin_websearch_enable">启用</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_icon">图标</system:String>
|
<system:String x:Key="wox_plugin_websearch_icon">图标</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_select_icon">选择图标</system:String>
|
<system:String x:Key="wox_plugin_websearch_select_icon">选择图标</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
|
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的网页搜索</system:String>
|
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的网页搜索</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_input_title">请输入标题</system:String>
|
<system:String x:Key="wox_plugin_websearch_input_title">请输入标题</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_input_action_keyword">请输入触发关键字</system:String>
|
<system:String x:Key="wox_plugin_websearch_input_action_keyword">请输入触发关键字</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_input_url">请输入URL</system:String>
|
<system:String x:Key="wox_plugin_websearch_input_url">请输入URL</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">触发关键字已经存在,请选择一个新的关键字</system:String>
|
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">触发关键字已经存在,请选择一个新的关键字</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
|
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_websearch_delete">刪除</system:String>
|
<system:String x:Key="wox_plugin_websearch_delete">刪除</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_edit">編輯</system:String>
|
<system:String x:Key="wox_plugin_websearch_edit">編輯</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
|
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_action_keyword">觸發關鍵字</system:String>
|
<system:String x:Key="wox_plugin_websearch_action_keyword">觸發關鍵字</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
|
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_enable_suggestion">啟用搜索建議</system:String>
|
<system:String x:Key="wox_plugin_websearch_enable_suggestion">啟用搜索建議</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">請選擇一項</system:String>
|
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">請選擇一項</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_delete_warning">你確定要刪除 {0} 嗎?</system:String>
|
<system:String x:Key="wox_plugin_websearch_delete_warning">你確定要刪除 {0} 嗎?</system:String>
|
||||||
|
|
||||||
|
|
||||||
<!--web search edit-->
|
<!--web search edit-->
|
||||||
<system:String x:Key="wox_plugin_websearch_title">標題</system:String>
|
<system:String x:Key="wox_plugin_websearch_title">標題</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_enable">啟用</system:String>
|
<system:String x:Key="wox_plugin_websearch_enable">啟用</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_icon">圖標</system:String>
|
<system:String x:Key="wox_plugin_websearch_icon">圖標</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_select_icon">選擇圖標</system:String>
|
<system:String x:Key="wox_plugin_websearch_select_icon">選擇圖標</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
|
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的網頁搜索</system:String>
|
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的網頁搜索</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_input_title">請輸入標題</system:String>
|
<system:String x:Key="wox_plugin_websearch_input_title">請輸入標題</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_input_action_keyword">請輸入觸發關鍵字</system:String>
|
<system:String x:Key="wox_plugin_websearch_input_action_keyword">請輸入觸發關鍵字</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_input_url">請輸入URL</system:String>
|
<system:String x:Key="wox_plugin_websearch_input_url">請輸入URL</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">觸發關鍵字已經存在,請選擇一個新的關鍵字</system:String>
|
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">觸發關鍵字已經存在,請選擇一個新的關鍵字</system:String>
|
||||||
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
|
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Wox.Core.Exception;
|
using Wox.Core.Exception;
|
||||||
|
using Wox.Core.UI;
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Infrastructure.Http;
|
using Wox.Infrastructure.Http;
|
||||||
@@ -91,12 +92,15 @@ namespace Wox.Core.Plugin
|
|||||||
plugins.AddRange(new CSharpPluginLoader().LoadPlugin(pluginMetadatas));
|
plugins.AddRange(new CSharpPluginLoader().LoadPlugin(pluginMetadatas));
|
||||||
plugins.AddRange(new JsonRPCPluginLoader<PythonPlugin>().LoadPlugin(pluginMetadatas));
|
plugins.AddRange(new JsonRPCPluginLoader<PythonPlugin>().LoadPlugin(pluginMetadatas));
|
||||||
|
|
||||||
|
//load plugin i18n languages
|
||||||
|
ResourceMerger.ApplyPluginLanguages();
|
||||||
|
|
||||||
foreach (PluginPair pluginPair in plugins)
|
foreach (PluginPair pluginPair in plugins)
|
||||||
{
|
{
|
||||||
PluginPair pair = pluginPair;
|
PluginPair pair = pluginPair;
|
||||||
ThreadPool.QueueUserWorkItem(o =>
|
ThreadPool.QueueUserWorkItem(o =>
|
||||||
{
|
{
|
||||||
using (new Timeit("Init Plugin: " + pair.Metadata.Name))
|
using (new Timeit(string.Format("Init {0}", pair.Metadata.Name)))
|
||||||
{
|
{
|
||||||
pair.Plugin.Init(new PluginInitContext()
|
pair.Plugin.Init(new PluginInitContext()
|
||||||
{
|
{
|
||||||
@@ -105,8 +109,7 @@ namespace Wox.Core.Plugin
|
|||||||
API = API
|
API = API
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ namespace Wox.Core.UI
|
|||||||
{
|
{
|
||||||
Application.Current.Resources.MergedDictionaries.Clear();
|
Application.Current.Resources.MergedDictionaries.Clear();
|
||||||
ApplyPluginLanguages();
|
ApplyPluginLanguages();
|
||||||
ApplyUIResources();
|
ApplyThemeAndLanguageResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ApplyUIResources()
|
private static void ApplyThemeAndLanguageResources()
|
||||||
{
|
{
|
||||||
var UIResourceType = typeof(IUIResource);
|
var UIResourceType = typeof(IUIResource);
|
||||||
var UIResources = AppDomain.CurrentDomain.GetAssemblies()
|
var UIResources = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
@@ -30,7 +30,7 @@ namespace Wox.Core.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ApplyPluginLanguages()
|
public static void ApplyPluginLanguages()
|
||||||
{
|
{
|
||||||
var pluginI18nType = typeof(IPluginI18n);
|
var pluginI18nType = typeof(IPluginI18n);
|
||||||
var pluginI18ns = AppDomain.CurrentDomain.GetAssemblies()
|
var pluginI18ns = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
|||||||
@@ -1,114 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
namespace Wox.Infrastructure.Hotkey
|
namespace Wox.Infrastructure.Hotkey
|
||||||
{
|
{
|
||||||
public enum KeyEvent : int
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Key down
|
|
||||||
/// </summary>
|
|
||||||
WM_KEYDOWN = 256,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Key up
|
|
||||||
/// </summary>
|
|
||||||
WM_KEYUP = 257,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// System key up
|
|
||||||
/// </summary>
|
|
||||||
WM_SYSKEYUP = 261,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// System key down
|
|
||||||
/// </summary>
|
|
||||||
WM_SYSKEYDOWN = 260
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class InterceptKeys
|
|
||||||
{
|
|
||||||
public delegate IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam);
|
|
||||||
|
|
||||||
private static int WH_KEYBOARD_LL = 13;
|
|
||||||
|
|
||||||
public static IntPtr SetHook(LowLevelKeyboardProc proc)
|
|
||||||
{
|
|
||||||
using (Process curProcess = Process.GetCurrentProcess())
|
|
||||||
using (ProcessModule curModule = curProcess.MainModule)
|
|
||||||
{
|
|
||||||
return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
||||||
public static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
public static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
||||||
public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, UIntPtr wParam, IntPtr lParam);
|
|
||||||
|
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
||||||
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
|
||||||
public static extern short GetKeyState(int keyCode);
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
internal static extern uint SendInput(uint nInputs, [MarshalAs(UnmanagedType.LPArray), In] INPUT[] pInputs, int cbSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
|
||||||
public struct INPUT
|
|
||||||
{
|
|
||||||
[FieldOffset(0)]
|
|
||||||
public Int32 type;//0-MOUSEINPUT;1-KEYBDINPUT;2-HARDWAREINPUT
|
|
||||||
[FieldOffset(4)]
|
|
||||||
public KEYBDINPUT ki;
|
|
||||||
[FieldOffset(4)]
|
|
||||||
public MOUSEINPUT mi;
|
|
||||||
[FieldOffset(4)]
|
|
||||||
public HARDWAREINPUT hi;
|
|
||||||
}
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public struct MOUSEINPUT
|
|
||||||
{
|
|
||||||
public Int32 dx;
|
|
||||||
public Int32 dy;
|
|
||||||
public Int32 mouseData;
|
|
||||||
public Int32 dwFlags;
|
|
||||||
public Int32 time;
|
|
||||||
public IntPtr dwExtraInfo;
|
|
||||||
}
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public struct KEYBDINPUT
|
|
||||||
{
|
|
||||||
public Int16 wVk;
|
|
||||||
public Int16 wScan;
|
|
||||||
public Int32 dwFlags;
|
|
||||||
public Int32 time;
|
|
||||||
public IntPtr dwExtraInfo;
|
|
||||||
}
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public struct HARDWAREINPUT
|
|
||||||
{
|
|
||||||
public Int32 uMsg;
|
|
||||||
public Int16 wParamL;
|
|
||||||
public Int16 wParamH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Listens keyboard globally.
|
/// Listens keyboard globally.
|
||||||
/// <remarks>Uses WH_KEYBOARD_LL.</remarks>
|
/// <remarks>Uses WH_KEYBOARD_LL.</remarks>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GlobalHotkey : IDisposable
|
public class GlobalHotkey : IDisposable
|
||||||
{
|
{
|
||||||
|
private static GlobalHotkey instance;
|
||||||
private InterceptKeys.LowLevelKeyboardProc hookedLowLevelKeyboardProc;
|
private InterceptKeys.LowLevelKeyboardProc hookedLowLevelKeyboardProc;
|
||||||
private IntPtr hookId = IntPtr.Zero;
|
private IntPtr hookId = IntPtr.Zero;
|
||||||
public delegate bool KeyboardCallback(KeyEvent keyEvent, int vkCode, SpecialKeyState state);
|
public delegate bool KeyboardCallback(KeyEvent keyEvent, int vkCode, SpecialKeyState state);
|
||||||
@@ -120,7 +23,19 @@ namespace Wox.Infrastructure.Hotkey
|
|||||||
private const int VK_ALT = 0x12;
|
private const int VK_ALT = 0x12;
|
||||||
private const int VK_WIN = 91;
|
private const int VK_WIN = 91;
|
||||||
|
|
||||||
public GlobalHotkey()
|
public static GlobalHotkey Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
instance = new GlobalHotkey();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private GlobalHotkey()
|
||||||
{
|
{
|
||||||
// We have to store the LowLevelKeyboardProc, so that it is not garbage collected runtime
|
// We have to store the LowLevelKeyboardProc, so that it is not garbage collected runtime
|
||||||
hookedLowLevelKeyboardProc = LowLevelKeyboardProc;
|
hookedLowLevelKeyboardProc = LowLevelKeyboardProc;
|
||||||
|
|||||||
38
Wox.Infrastructure/Hotkey/InterceptKeys.cs
Normal file
38
Wox.Infrastructure/Hotkey/InterceptKeys.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Wox.Infrastructure.Hotkey
|
||||||
|
{
|
||||||
|
internal static class InterceptKeys
|
||||||
|
{
|
||||||
|
public delegate IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
private const int WH_KEYBOARD_LL = 13;
|
||||||
|
|
||||||
|
public static IntPtr SetHook(LowLevelKeyboardProc proc)
|
||||||
|
{
|
||||||
|
using (Process curProcess = Process.GetCurrentProcess())
|
||||||
|
using (ProcessModule curModule = curProcess.MainModule)
|
||||||
|
{
|
||||||
|
return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
public static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, UIntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
public static extern short GetKeyState(int keyCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Wox.Infrastructure/Hotkey/KeyEvent.cs
Normal file
25
Wox.Infrastructure/Hotkey/KeyEvent.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
namespace Wox.Infrastructure.Hotkey
|
||||||
|
{
|
||||||
|
public enum KeyEvent:int
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Key down
|
||||||
|
/// </summary>
|
||||||
|
WM_KEYDOWN = 256,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Key up
|
||||||
|
/// </summary>
|
||||||
|
WM_KEYUP = 257,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System key up
|
||||||
|
/// </summary>
|
||||||
|
WM_SYSKEYUP = 261,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System key down
|
||||||
|
/// </summary>
|
||||||
|
WM_SYSKEYDOWN = 260
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,6 +59,8 @@
|
|||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Hotkey\InterceptKeys.cs" />
|
||||||
|
<Compile Include="Hotkey\KeyEvent.cs" />
|
||||||
<Compile Include="Logger\Log.cs" />
|
<Compile Include="Logger\Log.cs" />
|
||||||
<Compile Include="PeHeaderReader.cs" />
|
<Compile Include="PeHeaderReader.cs" />
|
||||||
<Compile Include="Storage\BinaryStorage.cs" />
|
<Compile Include="Storage\BinaryStorage.cs" />
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ namespace Wox.Plugin
|
|||||||
{
|
{
|
||||||
public delegate void WoxKeyDownEventHandler(object sender, WoxKeyDownEventArgs e);
|
public delegate void WoxKeyDownEventHandler(object sender, WoxKeyDownEventArgs e);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Global keyboard events
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keyevent">WM_KEYDOWN = 256,WM_KEYUP = 257,WM_SYSKEYUP = 261,WM_SYSKEYDOWN = 260</param>
|
||||||
|
/// <param name="vkcode"></param>
|
||||||
|
/// <param name="state"></param>
|
||||||
|
/// <returns>return true to continue handling, return false to intercept system handling</returns>
|
||||||
|
public delegate bool WoxGlobalKeyboardEventHandler(int keyevent, int vkcode, SpecialKeyState state);
|
||||||
|
|
||||||
public class WoxKeyDownEventArgs
|
public class WoxKeyDownEventArgs
|
||||||
{
|
{
|
||||||
public string Query { get; set; }
|
public string Query { get; set; }
|
||||||
|
|||||||
@@ -41,5 +41,7 @@ namespace Wox.Plugin
|
|||||||
List<PluginPair> GetAllPlugins();
|
List<PluginPair> GetAllPlugins();
|
||||||
|
|
||||||
event WoxKeyDownEventHandler BackKeyDownEvent;
|
event WoxKeyDownEventHandler BackKeyDownEvent;
|
||||||
|
|
||||||
|
event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace Wox
|
|||||||
Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
|
Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
|
||||||
|
|
||||||
string text = string.Empty;
|
string text = string.Empty;
|
||||||
SpecialKeyState specialKeyState = new GlobalHotkey().CheckModifiers();
|
SpecialKeyState specialKeyState = GlobalHotkey.Instance.CheckModifiers();
|
||||||
if (specialKeyState.AltPressed)
|
if (specialKeyState.AltPressed)
|
||||||
{
|
{
|
||||||
text += "Alt";
|
text += "Alt";
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -10,8 +12,6 @@ using System.Windows.Forms;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using WindowsInput;
|
|
||||||
using WindowsInput.Native;
|
|
||||||
using NHotkey;
|
using NHotkey;
|
||||||
using NHotkey.Wpf;
|
using NHotkey.Wpf;
|
||||||
using Wox.Core.i18n;
|
using Wox.Core.i18n;
|
||||||
@@ -21,25 +21,18 @@ using Wox.Core.UserSettings;
|
|||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Infrastructure.Hotkey;
|
using Wox.Infrastructure.Hotkey;
|
||||||
using Wox.Infrastructure.Storage;
|
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using Wox.Storage;
|
using Wox.Storage;
|
||||||
using Wox.Update;
|
using Wox.Update;
|
||||||
using Application = System.Windows.Application;
|
|
||||||
using Brushes = System.Windows.Media.Brushes;
|
using Brushes = System.Windows.Media.Brushes;
|
||||||
using Color = System.Windows.Media.Color;
|
using Color = System.Windows.Media.Color;
|
||||||
using ContextMenu = System.Windows.Forms.ContextMenu;
|
using ContextMenu = System.Windows.Forms.ContextMenu;
|
||||||
|
using DataFormats = System.Windows.DataFormats;
|
||||||
using DragEventArgs = System.Windows.DragEventArgs;
|
using DragEventArgs = System.Windows.DragEventArgs;
|
||||||
using FontFamily = System.Windows.Media.FontFamily;
|
|
||||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||||
using MenuItem = System.Windows.Forms.MenuItem;
|
using MenuItem = System.Windows.Forms.MenuItem;
|
||||||
using MessageBox = System.Windows.MessageBox;
|
using MessageBox = System.Windows.MessageBox;
|
||||||
using MouseButton = System.Windows.Input.MouseButton;
|
|
||||||
using Path = System.IO.Path;
|
|
||||||
using Rectangle = System.Drawing.Rectangle;
|
|
||||||
using TextBox = System.Windows.Controls.TextBox;
|
|
||||||
using ToolTip = System.Windows.Controls.ToolTip;
|
using ToolTip = System.Windows.Controls.ToolTip;
|
||||||
using Wox.Infrastructure.Logger;
|
|
||||||
|
|
||||||
namespace Wox
|
namespace Wox
|
||||||
{
|
{
|
||||||
@@ -48,10 +41,6 @@ namespace Wox
|
|||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
private static readonly object locker = new object();
|
|
||||||
public static bool initialized = false;
|
|
||||||
|
|
||||||
private static readonly List<Result> waitShowResultList = new List<Result>();
|
|
||||||
private readonly Storyboard progressBarStoryboard = new Storyboard();
|
private readonly Storyboard progressBarStoryboard = new Storyboard();
|
||||||
private NotifyIcon notifyIcon;
|
private NotifyIcon notifyIcon;
|
||||||
private bool queryHasReturn;
|
private bool queryHasReturn;
|
||||||
@@ -59,7 +48,6 @@ namespace Wox
|
|||||||
private ToolTip toolTip = new ToolTip();
|
private ToolTip toolTip = new ToolTip();
|
||||||
|
|
||||||
private bool ignoreTextChange = false;
|
private bool ignoreTextChange = false;
|
||||||
private readonly GlobalHotkey globalHotkey = new GlobalHotkey();
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -143,6 +131,7 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
|
|
||||||
public event WoxKeyDownEventHandler BackKeyDownEvent;
|
public event WoxKeyDownEventHandler BackKeyDownEvent;
|
||||||
|
public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent;
|
||||||
|
|
||||||
public void PushResults(Query query, PluginMetadata plugin, List<Result> results)
|
public void PushResults(Query query, PluginMetadata plugin, List<Result> results)
|
||||||
{
|
{
|
||||||
@@ -166,26 +155,27 @@ namespace Wox
|
|||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
ThreadPool.SetMaxThreads(30, 10);
|
||||||
|
ThreadPool.SetMinThreads(10, 5);
|
||||||
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow)
|
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow)
|
||||||
|
{
|
||||||
this.AllowsTransparency = true;
|
this.AllowsTransparency = true;
|
||||||
|
}
|
||||||
|
|
||||||
System.Net.WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
|
WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
|
||||||
|
GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
|
||||||
progressBar.ToolTip = toolTip;
|
progressBar.ToolTip = toolTip;
|
||||||
InitialTray();
|
InitialTray();
|
||||||
pnlResult.LeftMouseClickEvent += SelectResult;
|
pnlResult.LeftMouseClickEvent += SelectResult;
|
||||||
pnlContextMenu.LeftMouseClickEvent += SelectResult;
|
pnlContextMenu.LeftMouseClickEvent += SelectResult;
|
||||||
pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent;
|
pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent;
|
||||||
|
|
||||||
ThreadPool.SetMaxThreads(30, 10);
|
|
||||||
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
|
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||||
InternationalizationManager.Internationalization.ChangeLanguage(UserSettingStorage.Instance.Language);
|
InternationalizationManager.Internationalization.ChangeLanguage(UserSettingStorage.Instance.Language);
|
||||||
|
|
||||||
SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey);
|
SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey);
|
||||||
SetCustomPluginHotkey();
|
SetCustomPluginHotkey();
|
||||||
|
|
||||||
|
|
||||||
Closing += MainWindow_Closing;
|
Closing += MainWindow_Closing;
|
||||||
//since MainWIndow implement IPublicAPI, so we need to finish ctor MainWindow object before
|
//since MainWIndow implement IPublicAPI, so we need to finish ctor MainWindow object before
|
||||||
//PublicAPI invoke in plugin init methods. E.g FolderPlugin
|
//PublicAPI invoke in plugin init methods. E.g FolderPlugin
|
||||||
@@ -199,7 +189,16 @@ namespace Wox
|
|||||||
Thread.Sleep(50);
|
Thread.Sleep(50);
|
||||||
PreLoadImages();
|
PreLoadImages();
|
||||||
});
|
});
|
||||||
ThreadPool.QueueUserWorkItem(o => CheckUpdate());
|
CheckUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
|
||||||
|
{
|
||||||
|
if (GlobalKeyboardEvent != null)
|
||||||
|
{
|
||||||
|
return GlobalKeyboardEvent((int)keyevent, vkcode, state);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PreLoadImages()
|
private void PreLoadImages()
|
||||||
@@ -214,18 +213,21 @@ namespace Wox
|
|||||||
|
|
||||||
void CheckUpdate()
|
void CheckUpdate()
|
||||||
{
|
{
|
||||||
Release release = new UpdateChecker().CheckUpgrade();
|
ThreadPool.QueueUserWorkItem(o =>
|
||||||
if (release != null && !UserSettingStorage.Instance.DontPromptUpdateMsg)
|
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(new Action(() =>
|
Release release = new UpdateChecker().CheckUpgrade();
|
||||||
|
if (release != null && !UserSettingStorage.Instance.DontPromptUpdateMsg)
|
||||||
{
|
{
|
||||||
NewVersionWindow newVersinoWindow = new NewVersionWindow();
|
Dispatcher.Invoke(new Action(() =>
|
||||||
newVersinoWindow.Show();
|
{
|
||||||
}));
|
NewVersionWindow newVersinoWindow = new NewVersionWindow();
|
||||||
}
|
newVersinoWindow.Show();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
void MainWindow_Closing(object sender, CancelEventArgs e)
|
||||||
{
|
{
|
||||||
UserSettingStorage.Instance.WindowLeft = Left;
|
UserSettingStorage.Instance.WindowLeft = Left;
|
||||||
UserSettingStorage.Instance.WindowTop = Top;
|
UserSettingStorage.Instance.WindowTop = Top;
|
||||||
@@ -370,7 +372,7 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}, TimeSpan.FromSeconds(0), lastQuery);
|
}, TimeSpan.FromSeconds(0), lastQuery);
|
||||||
}
|
}
|
||||||
}, TimeSpan.FromMilliseconds(ShouldNotDelayQuery ? 0 : 150));
|
}, TimeSpan.FromMilliseconds(ShouldNotDelayQuery ? 0 : 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BackToResultMode()
|
private void BackToResultMode()
|
||||||
@@ -482,7 +484,7 @@ namespace Wox
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.Tab:
|
case Key.Tab:
|
||||||
if (globalHotkey.CheckModifiers().ShiftPressed)
|
if (GlobalHotkey.Instance.CheckModifiers().ShiftPressed)
|
||||||
{
|
{
|
||||||
SelectPrevItem();
|
SelectPrevItem();
|
||||||
}
|
}
|
||||||
@@ -534,7 +536,7 @@ namespace Wox
|
|||||||
|
|
||||||
case Key.Enter:
|
case Key.Enter:
|
||||||
Result activeResult = GetActiveResult();
|
Result activeResult = GetActiveResult();
|
||||||
if (globalHotkey.CheckModifiers().ShiftPressed)
|
if (GlobalHotkey.Instance.CheckModifiers().ShiftPressed)
|
||||||
{
|
{
|
||||||
ShowContextMenu(activeResult);
|
ShowContextMenu(activeResult);
|
||||||
}
|
}
|
||||||
@@ -600,7 +602,7 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
bool hideWindow = result.Action(new ActionContext()
|
bool hideWindow = result.Action(new ActionContext()
|
||||||
{
|
{
|
||||||
SpecialKeyState = globalHotkey.CheckModifiers()
|
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
|
||||||
});
|
});
|
||||||
if (hideWindow)
|
if (hideWindow)
|
||||||
{
|
{
|
||||||
@@ -611,7 +613,7 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnUpdateResultView(List<Result> list)
|
private void OnUpdateResultView(List<Result> list)
|
||||||
{
|
{
|
||||||
queryHasReturn = true;
|
queryHasReturn = true;
|
||||||
progressBar.Dispatcher.Invoke(new Action(StopProgress));
|
progressBar.Dispatcher.Invoke(new Action(StopProgress));
|
||||||
@@ -663,10 +665,10 @@ namespace Wox
|
|||||||
|
|
||||||
private void MainWindow_OnDrop(object sender, DragEventArgs e)
|
private void MainWindow_OnDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||||
{
|
{
|
||||||
// Note that you can have more than one file.
|
// Note that you can have more than one file.
|
||||||
string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
|
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||||
if (files[0].ToLower().EndsWith(".wox"))
|
if (files[0].ToLower().EndsWith(".wox"))
|
||||||
{
|
{
|
||||||
PluginManager.InstallPlugin(files[0]);
|
PluginManager.InstallPlugin(files[0]);
|
||||||
|
|||||||
@@ -105,48 +105,48 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
Title = "Wox is an effective launcher for windows",
|
Title = "Wox is an effective launcher for windows",
|
||||||
SubTitle = "Wox provide bundles of features let you access infomations quickly.",
|
SubTitle = "Wox provide bundles of features let you access infomations quickly.",
|
||||||
IcoPath = "Images/work.png",
|
IcoPath = "Images/app.png",
|
||||||
PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
|
PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
|
||||||
},
|
},
|
||||||
new Result()
|
new Result()
|
||||||
{
|
{
|
||||||
Title = "Search applications",
|
Title = "Search applications",
|
||||||
SubTitle = "Search applications, files (via everything plugin) and browser bookmarks",
|
SubTitle = "Search applications, files (via everything plugin) and browser bookmarks",
|
||||||
IcoPath = "Images/work.png",
|
IcoPath = "Images/app.png",
|
||||||
PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
|
PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
|
||||||
},
|
},
|
||||||
new Result()
|
new Result()
|
||||||
{
|
{
|
||||||
Title = "Search web contents with shortcuts",
|
Title = "Search web contents with shortcuts",
|
||||||
SubTitle = "e.g. search google with g keyword or youtube keyword)",
|
SubTitle = "e.g. search google with g keyword or youtube keyword)",
|
||||||
IcoPath = "Images/work.png",
|
IcoPath = "Images/app.png",
|
||||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||||
},
|
},
|
||||||
new Result()
|
new Result()
|
||||||
{
|
{
|
||||||
Title = "clipboard history ",
|
Title = "clipboard history ",
|
||||||
IcoPath = "Images/work.png",
|
IcoPath = "Images/app.png",
|
||||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||||
},
|
},
|
||||||
new Result()
|
new Result()
|
||||||
{
|
{
|
||||||
Title = "Themes support",
|
Title = "Themes support",
|
||||||
SubTitle = "get more themes from http://www.getwox.com/theme",
|
SubTitle = "get more themes from http://www.getwox.com/theme",
|
||||||
IcoPath = "Images/work.png",
|
IcoPath = "Images/app.png",
|
||||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||||
},
|
},
|
||||||
new Result()
|
new Result()
|
||||||
{
|
{
|
||||||
Title = "Plugins support",
|
Title = "Plugins support",
|
||||||
SubTitle = "get more plugins from http://www.getwox.com/plugin",
|
SubTitle = "get more plugins from http://www.getwox.com/plugin",
|
||||||
IcoPath = "Images/work.png",
|
IcoPath = "Images/app.png",
|
||||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||||
},
|
},
|
||||||
new Result()
|
new Result()
|
||||||
{
|
{
|
||||||
Title = "Wox is an open-source software",
|
Title = "Wox is an open-source software",
|
||||||
SubTitle = "Wox benefits from the open-source community a lot",
|
SubTitle = "Wox benefits from the open-source community a lot",
|
||||||
IcoPath = "Images/work.png",
|
IcoPath = "Images/app.png",
|
||||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user