Add kill process workflow
This commit is contained in:
parent
b6bbd6899e
commit
af954a0578
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
|
|
@ -34,16 +34,15 @@ namespace WinAlfred
|
|||
resultCtrl.resultItemChangedEvent += resultCtrl_resultItemChangedEvent;
|
||||
ThreadPool.SetMaxThreads(30, 10);
|
||||
InitProgressbarAnimation();
|
||||
WakeupApp();
|
||||
}
|
||||
|
||||
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 20min
|
||||
//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 * 30 * 1) { AutoReset = true, Enabled = true };
|
||||
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)
|
||||
|
@ -203,6 +202,7 @@ namespace WinAlfred
|
|||
InitialTray();
|
||||
selectedRecords.LoadSelectedRecords();
|
||||
SetAutoStart(true);
|
||||
WakeupApp();
|
||||
//var engine = new Jurassic.ScriptEngine();
|
||||
//MessageBox.Show(engine.Evaluate("5 * 10 + 2").ToString());
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ namespace WinAlfred
|
|||
public void CloseApp()
|
||||
{
|
||||
notifyIcon.Visible = false;
|
||||
Close();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
public void HideApp()
|
||||
|
|
Loading…
Reference in a new issue