mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev' into explorer_prompt_deletion
This commit is contained in:
commit
ccfcf5148f
20 changed files with 469 additions and 111 deletions
32
.github/ISSUE_TEMPLATE/bug-report.md
vendored
Normal file
32
.github/ISSUE_TEMPLATE/bug-report.md
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
name: "\U0001F41E Bug report"
|
||||
about: Create a bug report to help us improve Flow Launcher
|
||||
title: "[Describe Your Bug]"
|
||||
labels: 'bug'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug/issue**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. ...
|
||||
2. ...
|
||||
3. ...
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Your System**
|
||||
```
|
||||
Windows build number: (run "ver" at a command prompt)
|
||||
Flow Launcher version: (Settings => About)
|
||||
```
|
||||
**Flow Launcher Error Log**
|
||||
<!--
|
||||
The latest log file can be found here: %AppData%\FlowLauncher\Logs\<version>\<date>.txt
|
||||
or for portable mode: %LocalAppData%\FlowLauncher\<App-Version>\UserData\Logs\<version>\<date>.txt
|
||||
Drag and drop the log file below this comment.
|
||||
-->
|
||||
21
.github/ISSUE_TEMPLATE/code-review.md
vendored
Normal file
21
.github/ISSUE_TEMPLATE/code-review.md
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
name: "\U0001F50E Code Review"
|
||||
about: Describe (bad) code that needs to be improved
|
||||
title: "[Describe Problematic Code]"
|
||||
labels: 'code review'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Point to the corresponding file and line number(s) which could be improved.**
|
||||
|
||||
Click on the line number in GitHub to create an anchored link to the corresponding code section. For example:
|
||||
|
||||
|
||||
https://github.com/Flow-Launcher/Flow.Launcher/blob/master/Flow.Launcher/Storage/TopMostRecord.cs#L8
|
||||
|
||||
Provide your alternative implementation idea:
|
||||
|
||||
```
|
||||
Code
|
||||
```
|
||||
14
.github/ISSUE_TEMPLATE/discussion.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/discussion.md
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
name: "⁉️ Question/Discussion"
|
||||
about: Create a report to help us improve
|
||||
title: "[Ask a question or propose a change]"
|
||||
labels: 'question/discussion'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Question**
|
||||
Describe your question.
|
||||
|
||||
**Discussion**
|
||||
Discuss a topic.
|
||||
24
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
name: "⭐ Feature request"
|
||||
about: Suggest a new idea or a feature enhacement
|
||||
title: "[Describe Your Feature]"
|
||||
labels: 'enhancement'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
|
||||
Add any other context or screenshots about the feature request here.
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>1.0.0</Version>
|
||||
<PackageVersion>1.0.0</PackageVersion>
|
||||
<AssemblyVersion>1.0.0</AssemblyVersion>
|
||||
<FileVersion>1.0.0</FileVersion>
|
||||
<Version>1.1.0</Version>
|
||||
<PackageVersion>1.1.0</PackageVersion>
|
||||
<AssemblyVersion>1.1.0</AssemblyVersion>
|
||||
<FileVersion>1.1.0</FileVersion>
|
||||
<PackageId>Flow.Launcher.Plugin</PackageId>
|
||||
<Authors>Flow-Launcher</Authors>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher", "Flow.Launc
|
|||
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {A3DCCBCA-ACC1-421D-B16E-210896234C26}
|
||||
{049490F0-ECD2-4148-9B39-2135EC346EBE} = {049490F0-ECD2-4148-9B39-2135EC346EBE}
|
||||
{403B57F2-1856-4FC7-8A24-36AB346B763E} = {403B57F2-1856-4FC7-8A24-36AB346B763E}
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3} = {588088F4-3262-4F9F-9663-A05DE12534C3}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Infrastructure", "Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj", "{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}"
|
||||
|
|
@ -70,6 +71,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Calcul
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Explorer", "Plugins\Flow.Launcher.Plugin.Explorer\Flow.Launcher.Plugin.Explorer.csproj", "{F9C4C081-4CC3-4146-95F1-E102B4E10A5F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.ProcessKiller", "Plugins\Flow.Launcher.Plugin.ProcessKiller\Flow.Launcher.Plugin.ProcessKiller.csproj", "{588088F4-3262-4F9F-9663-A05DE12534C3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -297,6 +300,18 @@ Global
|
|||
{F9C4C081-4CC3-4146-95F1-E102B4E10A5F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{F9C4C081-4CC3-4146-95F1-E102B4E10A5F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F9C4C081-4CC3-4146-95F1-E102B4E10A5F}.Release|x86.Build.0 = Release|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Release|x64.Build.0 = Release|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -315,6 +330,7 @@ Global
|
|||
{9B130CC5-14FB-41FF-B310-0A95B6894C37} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
|
||||
{59BD9891-3837-438A-958D-ADC7F91F6F7E} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
|
||||
{F9C4C081-4CC3-4146-95F1-E102B4E10A5F} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
|
||||
{588088F4-3262-4F9F-9663-A05DE12534C3} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F26ACB50-3F6C-4907-B0C9-1ADACC1D0DED}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
</Style>
|
||||
|
||||
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
|
||||
<Setter Property="Width" Value="750" /> <!-- This is used to set the blur width only -->
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="Black" Opacity="0.3"/>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
</Style>
|
||||
|
||||
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
|
||||
<Setter Property="Width" Value="750" /> <!-- This is used to set the blur width only -->
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="White" Opacity="0.1"/>
|
||||
|
|
|
|||
|
|
@ -1,102 +0,0 @@
|
|||
<!--
|
||||
===================================================
|
||||
DO NOT DELETE UNTIL YOU HAVE READ THE FIRST SECTION
|
||||
===================================================
|
||||
|
||||
To be able to help you we need enough information to find
|
||||
what is causing your issue. Please follow the instructions
|
||||
and type the requested information where prompted.
|
||||
|
||||
===================================================
|
||||
中文版说明,请仔细阅读并在填写后删除此说明段落,无效的反馈会被直接关闭
|
||||
===================================================
|
||||
请遵循以下说明,提供我们所需要的信息来,这样我们才能找出导致你
|
||||
遇到的问题的原因,来更好的帮助你。
|
||||
如果可以的话,请附上一份英文的翻译(哪怕是直接使用谷歌翻译)
|
||||
请注意,无效的反馈(尤其是没有填写下面那些信息的反馈)会被直接关闭!
|
||||
-->
|
||||
|
||||
### Are you submitting a bug report?
|
||||
|
||||
(write your answer here)
|
||||
|
||||
<!--
|
||||
If your answer is "Yes", please follow the instructions below.
|
||||
|
||||
If your answer is "No", you may delete everything below and then proceed
|
||||
to write your concern.
|
||||
|
||||
你是否是在提交一个bug(软件缺陷)?
|
||||
如果你的答案是『是的』,请继续回答下面的提问。
|
||||
如果你的答案是『不是』,你可以删除下面的一切,然后说出你的想法。
|
||||
-->
|
||||
|
||||
<!--
|
||||
Some problems are known of and there are
|
||||
already workarounds or existing issues.
|
||||
|
||||
Known problems for 1.3.183:
|
||||
We are aware of the following issues and the following workarounds exist:
|
||||
1. `System.NullReferenceException`: https://github.com/Wox-launcher/Wox/releases/tag/v1.3.475
|
||||
2. `System.UriFormatException`: delete your old theme file
|
||||
3. `System.Threading.Tasks.TaskCanceledException`: https://github.com/Wox-launcher/Wox/releases/tag/v1.3.475
|
||||
4. `System.AggregateException`: see https://github.com/Wox-launcher/Wox/issues/1777
|
||||
|
||||
If none of them match your case, please continue.
|
||||
|
||||
已知问题及解决方案:(略,如果有任何问题请继续提问)
|
||||
-->
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
<!--
|
||||
Write what steps you took in order for this problem to happen.
|
||||
If you do not provide any steps, we cannot replicate your problem
|
||||
and will not be able to help you.
|
||||
|
||||
复现问题的步骤:
|
||||
在此按顺序一步步说明在问题发生前你做了什么操作。
|
||||
如果你没法说明你的步骤,那么我们无法复现你的问题,也就无法帮助你了。
|
||||
-->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### Flow Launcher Error Window text
|
||||
<!--
|
||||
Paste below the logs generated by the Flow.Launcher error reporter.
|
||||
|
||||
请在此处粘贴 Flow Launcher 错误报告程序提供的日志。
|
||||
-->
|
||||
|
||||
(paste here)
|
||||
|
||||
|
||||
### Detailed logs
|
||||
<!--
|
||||
Please also provide detailed logs. The latest log file
|
||||
can be found here: %APPDATA%\Flow.Launcher\Logs\version\<date>.txt
|
||||
Drag and drop that file below this comment.
|
||||
In some cases you can skip uploading the the logs, but the chances
|
||||
of us being able to solve the problem will be higher if you do.
|
||||
|
||||
详细日志:
|
||||
请在此处提供详细日志。你可以在这个目录找到最新的日志:
|
||||
%APPDATA%\Flow.Launcher\Logs\version\<date>.txt
|
||||
直接拖放文件到这个评论就可以上传(国内大部分地区可能需要翻墙才能上传,作为备选方案可以考虑直接在此粘贴文件内容)
|
||||
-->
|
||||
|
||||
(drop your log file here)
|
||||
|
||||
### Screenshots (optional)
|
||||
<!--
|
||||
If you think it will be helpful to provide a screenshot
|
||||
to better describe your problem, upload it below
|
||||
|
||||
截图(可选)
|
||||
如果你认为截图能够有助于说明你的问题,请在下面上传它。
|
||||
-->
|
||||
|
||||
(drop your screenshot here)
|
||||
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
"Name": "Explorer",
|
||||
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
|
||||
"Author": "Jeremy Wu",
|
||||
"Version": "1.0.0",
|
||||
"Version": "1.1.0",
|
||||
"Language": "csharp",
|
||||
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
||||
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AssemblyName>Flow.Launcher.Plugin.ProcessKiller</AssemblyName>
|
||||
<PackageId>Flow.Launcher.Plugin.ProcessKiller</PackageId>
|
||||
<Authors>Flow-Launcher</Authors>
|
||||
<PackageProjectUrl>https://github.com/Flow-Launcher/Flow.Launcher.Plugin.ProcessKiller</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/Flow-Launcher/Flow.Launcher.Plugin.ProcessKiller</RepositoryUrl>
|
||||
<PackageTags>flow-launcher flow-plugin</PackageTags>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.ProcessKiller\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Plugin.ProcessKiller\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Images\app.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Languages\en.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="plugin.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
BIN
Plugins/Flow.Launcher.Plugin.ProcessKiller/Images/app.png
Normal file
BIN
Plugins/Flow.Launcher.Plugin.ProcessKiller/Images/app.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
11
Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml
Normal file
11
Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<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="flowlauncher_plugin_processkiller_plugin_name">Process Killer</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_processkiller_plugin_description">Kill running processes from Flow Launcher</system:String>
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_processkiller_kill_all">kill all "{0}" processes</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_processkiller_kill_instances">kill all instances</system:String>
|
||||
|
||||
</ResourceDictionary>
|
||||
123
Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs
Normal file
123
Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.Dynamic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
|
||||
namespace Flow.Launcher.Plugin.ProcessKiller
|
||||
{
|
||||
public class Main : IPlugin, IPluginI18n, IContextMenu
|
||||
{
|
||||
private ProcessHelper processHelper = new ProcessHelper();
|
||||
|
||||
private static PluginInitContext _context;
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
var termToSearch = query.Terms.Length <= 1
|
||||
? null
|
||||
: string.Join(Plugin.Query.TermSeperater, query.Terms.Skip(1)).ToLower();
|
||||
|
||||
var processlist = processHelper.GetMatchingProcesses(termToSearch);
|
||||
|
||||
return !processlist.Any()
|
||||
? null
|
||||
: CreateResultsFromProcesses(processlist, termToSearch);
|
||||
}
|
||||
|
||||
public string GetTranslatedPluginTitle()
|
||||
{
|
||||
return _context.API.GetTranslation("flowlauncher_plugin_processkiller_plugin_name");
|
||||
}
|
||||
|
||||
public string GetTranslatedPluginDescription()
|
||||
{
|
||||
return _context.API.GetTranslation("flowlauncher_plugin_processkiller_plugin_description");
|
||||
}
|
||||
|
||||
public List<Result> LoadContextMenus(Result result)
|
||||
{
|
||||
var menuOptions = new List<Result>();
|
||||
var processPath = result.SubTitle;
|
||||
|
||||
// get all non-system processes whose file path matches that of the given result (processPath)
|
||||
var similarProcesses = processHelper.GetSimilarProcesses(processPath);
|
||||
|
||||
menuOptions.Add(new Result
|
||||
{
|
||||
Title = _context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_instances"),
|
||||
SubTitle = processPath,
|
||||
Action = _ =>
|
||||
{
|
||||
foreach (var p in similarProcesses)
|
||||
{
|
||||
processHelper.TryKill(p);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
IcoPath = processPath
|
||||
});
|
||||
|
||||
return menuOptions;
|
||||
}
|
||||
|
||||
private List<Result> CreateResultsFromProcesses(List<ProcessResult> processlist, string termToSearch)
|
||||
{
|
||||
var results = new List<Result>();
|
||||
|
||||
foreach (var pr in processlist)
|
||||
{
|
||||
var p = pr.Process;
|
||||
var path = processHelper.TryGetProcessFilename(p);
|
||||
results.Add(new Result()
|
||||
{
|
||||
IcoPath = path,
|
||||
Title = p.ProcessName + " - " + p.Id,
|
||||
SubTitle = path,
|
||||
TitleHighlightData = StringMatcher.FuzzySearch(termToSearch, p.ProcessName).MatchData,
|
||||
Score = pr.Score,
|
||||
Action = (c) =>
|
||||
{
|
||||
processHelper.TryKill(p);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// When there are multiple results AND all of them are instances of the same executable
|
||||
// add a quick option to kill them all at the top of the results.
|
||||
var firstResult = results.FirstOrDefault()?.SubTitle;
|
||||
if (processlist.Count > 1 && !string.IsNullOrEmpty(termToSearch) && results.All(r => r.SubTitle == firstResult))
|
||||
{
|
||||
results.Insert(0, new Result()
|
||||
{
|
||||
IcoPath = "Images/app.png",
|
||||
Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), termToSearch),
|
||||
SubTitle = "",
|
||||
Score = 200,
|
||||
Action = (c) =>
|
||||
{
|
||||
foreach (var p in processlist)
|
||||
{
|
||||
processHelper.TryKill(p.Process);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
125
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs
Normal file
125
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Flow.Launcher.Plugin.ProcessKiller
|
||||
{
|
||||
internal class ProcessHelper
|
||||
{
|
||||
private readonly HashSet<string> _systemProcessList = new HashSet<string>()
|
||||
{
|
||||
"conhost",
|
||||
"svchost",
|
||||
"idle",
|
||||
"system",
|
||||
"rundll32",
|
||||
"csrss",
|
||||
"lsass",
|
||||
"lsm",
|
||||
"smss",
|
||||
"wininit",
|
||||
"winlogon",
|
||||
"services",
|
||||
"spoolsv",
|
||||
"explorer"
|
||||
};
|
||||
|
||||
private bool IsSystemProcess(Process p) => _systemProcessList.Contains(p.ProcessName.ToLower());
|
||||
|
||||
/// <summary>
|
||||
/// Returns a ProcessResult for evey running non-system process whose name matches the given searchTerm
|
||||
/// </summary>
|
||||
public List<ProcessResult> GetMatchingProcesses(string searchTerm)
|
||||
{
|
||||
var processlist = new List<ProcessResult>();
|
||||
|
||||
foreach (var p in Process.GetProcesses())
|
||||
{
|
||||
if (IsSystemProcess(p)) continue;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(searchTerm))
|
||||
{
|
||||
// show all non-system processes
|
||||
processlist.Add(new ProcessResult(p, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
var score = StringMatcher.FuzzySearch(searchTerm, p.ProcessName + p.Id).Score;
|
||||
if (score > 0)
|
||||
{
|
||||
processlist.Add(new ProcessResult(p, score));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return processlist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all non-system processes whose file path matches the given processPath
|
||||
/// </summary>
|
||||
public IEnumerable<Process> GetSimilarProcesses(string processPath)
|
||||
{
|
||||
return Process.GetProcesses().Where(p => !IsSystemProcess(p) && TryGetProcessFilename(p) == processPath);
|
||||
}
|
||||
|
||||
public void TryKill(Process p)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!p.HasExited)
|
||||
{
|
||||
p.Kill();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception($"|ProcessKiller.CreateResultsFromProcesses|Failed to kill process {p.ProcessName}", e);
|
||||
}
|
||||
}
|
||||
|
||||
public string TryGetProcessFilename(Process p)
|
||||
{
|
||||
try
|
||||
{
|
||||
int capacity = 2000;
|
||||
StringBuilder builder = new StringBuilder(capacity);
|
||||
IntPtr ptr = OpenProcess(ProcessAccessFlags.QueryLimitedInformation, false, p.Id);
|
||||
if (!QueryFullProcessImageName(ptr, 0, builder, ref capacity))
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum ProcessAccessFlags : uint
|
||||
{
|
||||
QueryLimitedInformation = 0x00001000
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool QueryFullProcessImageName(
|
||||
[In] IntPtr hProcess,
|
||||
[In] int dwFlags,
|
||||
[Out] StringBuilder lpExeName,
|
||||
ref int lpdwSize);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern IntPtr OpenProcess(
|
||||
ProcessAccessFlags processAccess,
|
||||
bool bInheritHandle,
|
||||
int processId);
|
||||
}
|
||||
}
|
||||
17
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessResult.cs
Normal file
17
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessResult.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace Flow.Launcher.Plugin.ProcessKiller
|
||||
{
|
||||
internal class ProcessResult
|
||||
{
|
||||
public ProcessResult(Process process, int score)
|
||||
{
|
||||
Process = process;
|
||||
Score = score;
|
||||
}
|
||||
|
||||
public Process Process { get; }
|
||||
|
||||
public int Score { get; }
|
||||
}
|
||||
}
|
||||
8
Plugins/Flow.Launcher.Plugin.ProcessKiller/Readme.md
Normal file
8
Plugins/Flow.Launcher.Plugin.ProcessKiller/Readme.md
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Process Killer Plugin
|
||||
=====================
|
||||
|
||||
A Flow-Launcher plugin that allows you to kill running processes.
|
||||
|
||||
Based on Wox.Plugin.ProcessKiller, originally created by [cxfksword](https://github.com/cxfksword/Wox.Plugin.ProcessKiller) and improved by [theClueless](https://github.com/theClueless/Wox.Plugins/tree/master/Wox.Plugin.ProcessKiller).
|
||||
|
||||

|
||||
12
Plugins/Flow.Launcher.Plugin.ProcessKiller/plugin.json
Normal file
12
Plugins/Flow.Launcher.Plugin.ProcessKiller/plugin.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"ID":"b64d0a79-329a-48b0-b53f-d658318a1bf6",
|
||||
"ActionKeyword":"kill",
|
||||
"Name":"Process Killer",
|
||||
"Description":"kill running processes from Flow",
|
||||
"Author":"Flow-Launcher",
|
||||
"Version":"1.0.0",
|
||||
"Language":"csharp",
|
||||
"Website":"https://github.com/Flow-Launcher/Flow.Launcher.Plugin.ProcessKiller",
|
||||
"IcoPath":"Images\\app.png",
|
||||
"ExecuteFileName":"Flow.Launcher.Plugin.ProcessKiller.dll"
|
||||
}
|
||||
|
|
@ -16,6 +16,6 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.0")]
|
||||
[assembly: AssemblyVersion("1.1.1")]
|
||||
[assembly: AssemblyFileVersion("1.1.1")]
|
||||
[assembly: AssemblyInformationalVersion("1.1.1")]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
version: '1.0.0.{build}'
|
||||
version: '1.1.1.{build}'
|
||||
|
||||
init:
|
||||
- ps: |
|
||||
|
|
|
|||
Loading…
Reference in a new issue