mirror of
https://github.com/fofolee/uTools-ProcessKiller.git
synced 2025-06-08 14:24:05 +08:00
增加右键重启进程功能
This commit is contained in:
parent
500f314742
commit
6072b135e8
47
index.html
47
index.html
@ -14,18 +14,23 @@
|
||||
<div id="tasklist"></div>
|
||||
<div id="infopannel"></div>
|
||||
<script>
|
||||
kill = taskname => {
|
||||
window.taskkill(taskname, err => {
|
||||
kill = (taskname, taskpath) => {
|
||||
window.taskkill(taskname, taskpath, err => {
|
||||
if (err) {
|
||||
$("#infopannel").css({ "background": "#EF5350" });
|
||||
$("#infopannel").html(err).fadeIn(300).delay(4000).fadeOut(300);
|
||||
$("#infopannel").html(err).fadeIn(300).delay(3000).fadeOut(300);
|
||||
} else {
|
||||
$("[name='" + taskname + "']").fadeOut(300).remove()
|
||||
let tasknum = $(".taskinfo").length
|
||||
utools.setExpendHeight(tasknum > 10 ? 500 : 50 * tasknum);
|
||||
window.tasklist((task) => {
|
||||
window.tasks = task
|
||||
});
|
||||
if(taskpath == undefined){
|
||||
$("[name='" + taskname + "']").fadeOut(300).remove()
|
||||
let tasknum = $(".taskinfo").length
|
||||
utools.setExpendHeight(tasknum > 10 ? 500 : 50 * tasknum);
|
||||
window.tasklist((task) => {
|
||||
window.tasks = task
|
||||
});
|
||||
}else{
|
||||
$("#infopannel").css({ "background": "#83bf40" });
|
||||
$("#infopannel").html('重启进程成功!').fadeIn(300).delay(3000).fadeOut(300);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -38,21 +43,29 @@
|
||||
for (var t of window.tasks) {
|
||||
if (t.ProcessName.toUpperCase().search(text.toUpperCase()) != -1 || t.Description.toUpperCase().search(text.toUpperCase()) != -1) {
|
||||
let title = t.Description ? t.Description : t.ProcessName;
|
||||
taskinfo += '<div class="taskinfo" name="' + t.ProcessName + '" onclick=\'kill("' + t.ProcessName + '")\'><img src="file:///' + t.Icon + '">';
|
||||
taskinfo += '<div class="taskinfo" name="' + t.ProcessName + '">';
|
||||
taskinfo += '<img src="file:///' + t.Icon + '">';
|
||||
taskinfo += '<div class="description">' + title + '</div><div class="path">' + t.Path + '</div></div>';
|
||||
}
|
||||
}
|
||||
$("#tasklist").html(taskinfo);
|
||||
let tasknum = $(".taskinfo").length
|
||||
utools.setExpendHeight(tasknum > 10 ? 500 : 50 * tasknum);
|
||||
}, '输入进程名,回车关闭,或点击关闭');
|
||||
}, '输入进程名,回车关闭,或点击关闭');
|
||||
});
|
||||
});
|
||||
$("#tasklist").on('mousedown', '.taskinfo', function (e) {
|
||||
if (1 == e.which) {
|
||||
kill($(this).attr('name'));
|
||||
}else if(3 == e.which){
|
||||
kill($(this).attr('name'), $(this).children(".path").html().replace(/\\/g,'/'))
|
||||
}
|
||||
});
|
||||
$(document).keydown(e => {
|
||||
if (e.keyCode === 13) {
|
||||
kill($(".taskinfo").attr('name'));
|
||||
}
|
||||
});
|
||||
});
|
||||
$(document).keydown(e => {
|
||||
if (e.keyCode === 13) {
|
||||
kill($(".taskinfo").attr('name'));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
@ -51,8 +51,12 @@ tasklist = (callback) => {
|
||||
});
|
||||
}
|
||||
|
||||
taskkill = (taskname, callback) => {
|
||||
let ps = new PowerShell(`chcp 65001;Stop-Process -Name ${taskname}`);
|
||||
taskkill = (taskname, taskpath, callback) => {
|
||||
if (taskpath == undefined) {
|
||||
var ps = new PowerShell(`chcp 65001;Stop-Process -Name ${taskname}`);
|
||||
} else {
|
||||
var ps = new PowerShell(`chcp 65001;Stop-Process -Name ${taskname};Start-Process -FilePath "${taskpath}"`);
|
||||
}
|
||||
ps.on("error-output", data => {
|
||||
callback(data.split('\n')[0])
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user