|
🧐 感觉直接使用命令应该没办法吧,命令都是直接强制结束进程的。我能想到的方法是使用 AHK 关闭窗口,例如:
- #Requires AutoHotkey v2
- targetPath := "path\to\your\chrome.exe"
- hwndList := WinGetList()
- pidsClosed := []
- for hwnd in hwndList
- {
- pid := WinGetPid(hwnd)
- if (pidsClosed.Has(pid))
- {
- continue
- }
- try
- {
- name := ProcessGetName(pid)
- path := ProcessGetPath(pid)
- }
- catch
- {
- continue
- }
- if (name && StrCompare(name, "chrome.exe", true) == 0 && path && StrCompare(path, targetPath, true) == 0)
- {
- hwnds := WinGetList("ahk_pid " pid)
- for h in hwnds
- WinClose("ahk_id " h)
- pidsClosed.Push(pid)
- }
- }
- StrCompare(str1, str2, ignoreCase := false)
- {
- if (ignoreCase)
- {
- str1 := StrLower(str1)
- str2 := StrLower(str2)
- }
- return (str1 == str2) ? 0 : 1
- }
复制代码
|
|