Merge branch 'master' of https://github.com/qianlifeng/WinAlfred.git
This commit is contained in:
commit
93d8f66afc
BIN
Plugins/WinAlfred.Plugin.Kill/Images/app.png
Normal file
BIN
Plugins/WinAlfred.Plugin.Kill/Images/app.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
36
Plugins/WinAlfred.Plugin.Kill/main.py
Normal file
36
Plugins/WinAlfred.Plugin.Kill/main.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#encoding=utf8
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import psutil
|
||||||
|
import json
|
||||||
|
|
||||||
|
def signalResult(process):
|
||||||
|
res = {}
|
||||||
|
res["Title"] = process.name
|
||||||
|
res["SubTitle"] = process.pid
|
||||||
|
res["ActionName"] = "killProcess"
|
||||||
|
res["IcoPath"] = "Images\\app.png"
|
||||||
|
res["ActionPara"] = process.pid
|
||||||
|
return res
|
||||||
|
|
||||||
|
def query(key):
|
||||||
|
name = key.split(" ")[1]
|
||||||
|
results = []
|
||||||
|
for i in psutil.get_process_list():
|
||||||
|
try:
|
||||||
|
if name:
|
||||||
|
if name.lower() in i.name.lower():
|
||||||
|
results.append(signalResult(i))
|
||||||
|
else:
|
||||||
|
results.append(signalResult(i))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return json.dumps(results)
|
||||||
|
|
||||||
|
def killProcess(pid):
|
||||||
|
p = psutil.Process(int(pid))
|
||||||
|
if p:
|
||||||
|
p.kill()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print killProcess(10008)
|
8
Plugins/WinAlfred.Plugin.Kill/plugin.ini
Normal file
8
Plugins/WinAlfred.Plugin.Kill/plugin.ini
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[plugin]
|
||||||
|
ActionKeyword = kill
|
||||||
|
Name = WinAlfred.Kill
|
||||||
|
Author = qianlifeng
|
||||||
|
Version = 0.1
|
||||||
|
Language = python
|
||||||
|
Description = kill process
|
||||||
|
ExecuteFile = main.py
|
|
@ -22,3 +22,8 @@ Create workflow
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Currently, WinAlfred support using C# and Python to write your workflows. Please refer to [Create-workflows](https://github.com/qianlifeng/WinAlfred/wiki/Create-workflows) page for more infomation.
|
Currently, WinAlfred support using C# and Python to write your workflows. Please refer to [Create-workflows](https://github.com/qianlifeng/WinAlfred/wiki/Create-workflows) page for more infomation.
|
||||||
|
|
||||||
|
Share workflow
|
||||||
|
=========
|
||||||
|
|
||||||
|
Share your workflows through <a href="http://winalfred.scottqian.com/">WinAlfredWorkflows</a>. After you upload your workflow, other uses can download or search your workflow through `wf` command (this is a workflow for workflow management , which is the one of the default workflows inside winalfred).
|
||||||
|
|
|
@ -113,14 +113,12 @@ Global
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Any CPU.ActiveCfg = Release|Any CPU
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Any CPU.Build.0 = Release|Any CPU
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Any CPU.Build.0 = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Mixed Platforms.ActiveCfg = Release|x86
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Mixed Platforms.Build.0 = Release|x86
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Win32.ActiveCfg = Release|x86
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Win32.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|Win32.Build.0 = Release|x86
|
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|x64.ActiveCfg = Release|x64
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|x64.ActiveCfg = Release|x64
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|x64.Build.0 = Release|x64
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|x64.Build.0 = Release|x64
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|x86.ActiveCfg = Release|x86
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|x86.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.EmbeddingTest|x86.Build.0 = Release|x86
|
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.Build.0 = Release|Any CPU
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
@ -130,14 +128,12 @@ Global
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.ActiveCfg = Release|Any CPU
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Any CPU.ActiveCfg = Release|Any CPU
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Any CPU.Build.0 = Release|Any CPU
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Any CPU.Build.0 = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Mixed Platforms.ActiveCfg = Release|x86
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Mixed Platforms.Build.0 = Release|x86
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Win32.ActiveCfg = Release|x86
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Win32.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|Win32.Build.0 = Release|x86
|
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|x64.ActiveCfg = Release|x64
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|x64.ActiveCfg = Release|x64
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|x64.Build.0 = Release|x64
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|x64.Build.0 = Release|x64
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|x86.ActiveCfg = Release|x86
|
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|x86.ActiveCfg = Release|Any CPU
|
||||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.UnitTests|x86.Build.0 = Release|x86
|
|
||||||
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
|
|
@ -10,7 +10,12 @@ namespace WinAlfred.Commands
|
||||||
{
|
{
|
||||||
private MainWindow window;
|
private MainWindow window;
|
||||||
|
|
||||||
public abstract void Dispatch(Query query);
|
public void Dispatch(Query query)
|
||||||
|
{
|
||||||
|
Dispatch(query, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void Dispatch(Query query, bool updateView);
|
||||||
|
|
||||||
//TODO:Ugly, we should subscribe events here, instead of just use usercontrol as the parameter
|
//TODO:Ugly, we should subscribe events here, instead of just use usercontrol as the parameter
|
||||||
protected BaseCommand(MainWindow window)
|
protected BaseCommand(MainWindow window)
|
||||||
|
|
|
@ -23,5 +23,11 @@ namespace WinAlfred.Commands
|
||||||
systemCmd.Dispatch(query);
|
systemCmd.Dispatch(query);
|
||||||
pluginCmd.Dispatch(query);
|
pluginCmd.Dispatch(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DispatchCommand(Query query,bool updateView)
|
||||||
|
{
|
||||||
|
systemCmd.Dispatch(query,updateView);
|
||||||
|
pluginCmd.Dispatch(query,updateView);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace WinAlfred.Commands
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispatch(Query q)
|
public override void Dispatch(Query q,bool updateView)
|
||||||
{
|
{
|
||||||
PluginPair thirdPlugin = Plugins.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == q.ActionName);
|
PluginPair thirdPlugin = Plugins.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == q.ActionName);
|
||||||
if (thirdPlugin != null && !string.IsNullOrEmpty(thirdPlugin.Metadata.ActionKeyword))
|
if (thirdPlugin != null && !string.IsNullOrEmpty(thirdPlugin.Metadata.ActionKeyword))
|
||||||
|
@ -39,7 +39,7 @@ namespace WinAlfred.Commands
|
||||||
o.PluginDirectory = thirdPlugin.Metadata.PluginDirecotry;
|
o.PluginDirectory = thirdPlugin.Metadata.PluginDirecotry;
|
||||||
o.OriginQuery = q;
|
o.OriginQuery = q;
|
||||||
});
|
});
|
||||||
UpdateResultView(r);
|
if(updateView) UpdateResultView(r);
|
||||||
}
|
}
|
||||||
catch (Exception queryException)
|
catch (Exception queryException)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace WinAlfred.Commands
|
||||||
systemPlugins = Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System).ToList();
|
systemPlugins = Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispatch(Query query)
|
public override void Dispatch(Query query,bool updateView)
|
||||||
{
|
{
|
||||||
foreach (PluginPair pair in systemPlugins)
|
foreach (PluginPair pair in systemPlugins)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ namespace WinAlfred.Commands
|
||||||
result.PluginDirectory = pair1.Metadata.PluginDirecotry;
|
result.PluginDirectory = pair1.Metadata.PluginDirecotry;
|
||||||
result.OriginQuery = query;
|
result.OriginQuery = query;
|
||||||
}
|
}
|
||||||
if(results.Count > 0) UpdateResultView(results);
|
if(results.Count > 0 && updateView) UpdateResultView(results);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,19 +7,12 @@ using System.Windows.Controls;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using System.Windows.Shapes;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
using Microsoft.Win32;
|
|
||||||
using WinAlfred.Commands;
|
using WinAlfred.Commands;
|
||||||
using WinAlfred.Helper;
|
using WinAlfred.Helper;
|
||||||
using WinAlfred.Plugin;
|
using WinAlfred.Plugin;
|
||||||
using WinAlfred.PluginLoader;
|
using WinAlfred.PluginLoader;
|
||||||
using DataFormats = System.Windows.DataFormats;
|
|
||||||
using DragDropEffects = System.Windows.DragDropEffects;
|
|
||||||
using DragEventArgs = System.Windows.DragEventArgs;
|
|
||||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||||
using MessageBox = System.Windows.MessageBox;
|
using MessageBox = System.Windows.MessageBox;
|
||||||
using Timer = System.Threading.Timer;
|
|
||||||
|
|
||||||
namespace WinAlfred
|
namespace WinAlfred
|
||||||
{
|
{
|
||||||
|
@ -43,6 +36,27 @@ namespace WinAlfred
|
||||||
InitProgressbarAnimation();
|
InitProgressbarAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WakeupApp()
|
||||||
|
{
|
||||||
|
//After hide winalfred in the background for a long time. It will become very slow in the next show.
|
||||||
|
//This is caused by the Virtual Mermory Page Mechanisam. So, our solution is execute some codes in every min
|
||||||
|
//which may prevent sysetem uninstall memory from RAM to disk.
|
||||||
|
|
||||||
|
System.Timers.Timer t = new System.Timers.Timer(1000 * 60 * 3) { AutoReset = true, Enabled = true };
|
||||||
|
t.Elapsed += (o, e) => Dispatcher.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
if (Visibility != Visibility.Visible)
|
||||||
|
{
|
||||||
|
double oldLeft = Left;
|
||||||
|
Left = 20000;
|
||||||
|
ShowWinAlfred();
|
||||||
|
cmdDispatcher.DispatchCommand(new Query("qq"),false);
|
||||||
|
HideWinAlfred();
|
||||||
|
Left = oldLeft;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
private void InitProgressbarAnimation()
|
private void InitProgressbarAnimation()
|
||||||
{
|
{
|
||||||
DoubleAnimation da = new DoubleAnimation(progressBar.X2, Width + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
|
DoubleAnimation da = new DoubleAnimation(progressBar.X2, Width + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
|
||||||
|
@ -188,6 +202,7 @@ namespace WinAlfred
|
||||||
InitialTray();
|
InitialTray();
|
||||||
selectedRecords.LoadSelectedRecords();
|
selectedRecords.LoadSelectedRecords();
|
||||||
SetAutoStart(true);
|
SetAutoStart(true);
|
||||||
|
WakeupApp();
|
||||||
//var engine = new Jurassic.ScriptEngine();
|
//var engine = new Jurassic.ScriptEngine();
|
||||||
//MessageBox.Show(engine.Evaluate("5 * 10 + 2").ToString());
|
//MessageBox.Show(engine.Evaluate("5 * 10 + 2").ToString());
|
||||||
}
|
}
|
||||||
|
@ -258,7 +273,7 @@ namespace WinAlfred
|
||||||
public void CloseApp()
|
public void CloseApp()
|
||||||
{
|
{
|
||||||
notifyIcon.Visible = false;
|
notifyIcon.Visible = false;
|
||||||
Close();
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HideApp()
|
public void HideApp()
|
||||||
|
|
Loading…
Reference in a new issue