Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to kill "not responding" apps? #134

Closed
AromaKitsune opened this issue Dec 9, 2021 · 16 comments
Closed

Possible to kill "not responding" apps? #134

AromaKitsune opened this issue Dec 9, 2021 · 16 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@AromaKitsune
Copy link

AromaKitsune commented Dec 9, 2021

I've mentioned about SuperF4 not being able to kill the unresponsive app, forcing us to launch Task Manager to kill this process.
stefansundin/superf4#38

AltSnap can't do it too, I tried Ctrl+Alt+F4 or Alt+(Left/Middle/Right)MouseButton as "Kill program", does nothing...

Would it be possible to terminate the unresponsive app process without Task Manager?

@RamonUnch
Copy link
Owner

Which version of Windows are you using? are-you running AltSnap Elevated?

@RamonUnch
Copy link
Owner

Well now I understand the problem, I will see what I can do. it seems quite hard because I cannot even get the handle to the window from the mouse cursor, so I am not sure it is even possible.

@AromaKitsune
Copy link
Author

Currently, I'm on Windows 11 21H2, I always run AltSnap as admin.

I have an idea, try the Alt+Tab method. While holding down Alt, we can close the selected app by pressing Del.
Maybe we can do that with Alt+Shift+Del to force close an app while Alt-Tabbing?

@RamonUnch
Copy link
Owner

I have an idea, try the Alt+Tab method. While holding down Alt, we can close the selected app by pressing Del.
Maybe we can do that with Alt+Shift+Del to force close an app while Alt-Tabbing?

This would be great but unfortunately, this requires integration into the Alt+Tab window manager and this can be done only by Microsoft. What AltDrag does is simply manipulate windows from the outside using conventional Windows API.

So what happens is that after 5 sec of unresponsiveness for an application the Explorer will hide the actual window and present a special Ghost window, that can be moved/minimized/closed by the user.
So if you Use Ctrl+Alt+F4 before the 5 second delay, verything works as expected.
If you wait for the ..Not responding sufix, at this poment it is no longer the real window but a ghost, so when you Press Ctrl+Alt+F4, AltSnap see an explorer window and does not terminate it because no one wants to terminate the explorer by accident.

Hence, I need to find a way to get the windows handle from the Ghost window information and the only thing I got is a modified window title...

@RamonUnch
Copy link
Owner

PS: Normally as soon as those 5 secs elapses, A simple Alt+F4 should propose to terminate the program, so I am not sure what the point would be? AltSnap can still be used to terminate programs that are hung but not detected or not yet detected by Windows.

@RamonUnch RamonUnch added bug Something isn't working enhancement New feature or request labels Dec 10, 2021
@RamonUnch
Copy link
Owner

@Yarrio69
In The latest 1.49 release, as soon as a window is a "ghost" window, AltSnap sends the WM_CLOSE Message, and the end process confirmation dialog should appear. For me it works, tell me if it helps you.

@AromaKitsune
Copy link
Author

Hmm, the dialog doesn't appear for me.

2022-01-20_19-25-40_explorer

@RamonUnch
Copy link
Owner

RamonUnch commented Jan 20, 2022

Does it appear when you hit the close button?
Could you show me the content of the "Identify window" option in [balckist tab] when the application is not responding. it should show something like: Untitled - Notepad (Not Responding)|Ghost
This is the case on WinXP/7, I do not have Win10 anymore and never got Win11

@AromaKitsune
Copy link
Author

Yep, the hung app can be force closed by spamming the close button too.
I'll setup Windows 7 VM and test it when I get a chance.

image
2022-01-20_22-53-30_AltSnap

This is what it should appear right?
image

@RamonUnch
Copy link
Owner

RamonUnch commented Jan 21, 2022

Thanks for the details, the only thing I did not expect is to see the WM_NCHITTEST to 0, I will see if this is the reason.
EDIT: Yes the dialog you are showing should appear.

@AromaKitsune
Copy link
Author

AromaKitsune commented May 1, 2022

@RamonUnch I think I found the solution: https://winaero.com/kill-not-responding-tasks-windows-10/

We can terminate non-responding apps with taskkill.exe /F /FI "status eq NOT RESPONDING"

This terminates ALL non-responding apps it finds, it's not very common to have more than one hung apps at the same time.
Maybe it can be integrated into AltSnap and mapped to Ctrl+Shift+Alt+F4.

The problem is if this taskkill command is used with admin privilege, it also kills DWM if atleast one hung app is found, causing the screen to blackout for a second, so adding dwm.exe to Blacklist would prevent this.
For some reason, it sometimes terminates AltSnap too.

Screenshot 2022-05-01 145322

@RamonUnch
Copy link
Owner

Interesting indeed.

The taskkill command is its own thing, it would not care about any blacklist, blacklist are internally handled by AltSnap.
A solution could be to launch this command line without elevation (it is should possible using Create­Process())

Windows is using a very simple heuristics to determine if a process is hung or not and this is quite risky in my opinion to launch this command line even at non admin level. Of course risky only if you get some running processes with unsaved data.

I will see on how to implement this in AltSnap, it might come with a different keyboard shortcut or with a confirmation dialog...

In the meantime maybe you can simply create a desktop shortcut with the command line (like described on winaero) and configure the keyboard shortcut so that it triggers on Ctrl+Shift+Alt+F4 or something.

I mean this trick does not need AltSnap or any extra programs to be launched from a keyboard shortcut...
Also the advantage of the desktop shortcut is to launch the command without admin privilege.

@RamonUnch
Copy link
Owner

In case I was not clear on windows when you create a desktop shortcut you can setup a keyboard shortcut by pressing the correct key combo in the Shortcut key: field in the property sheet of the desktop shortcut.
Image1

@RamonUnch
Copy link
Owner

Also even more important you can exclude some processes from the list with the IMAGENAME filter:
According to the documentation, the IMAGENAME filter can be used to check for processes to include or exclude.
Fo you could run instead:

taskkill.exe /F /FI "status eq NOT RESPONDING" /FI "IMAGENAME ne AltSnap.exe" /FI "IMAGENAME ne dwm.exe"

I could not test this, try by yourself. Add more processes if needed...

@AromaKitsune
Copy link
Author

AromaKitsune commented May 3, 2022

Yep, it works. The .lnk Shortcut Key method has a delay before executing a command, so I used AutoHotkey instead, it's more effective and instant.
I guess that feature doesn't need to be added to AltSnap then. ¯\_(ツ)_/¯

Here's the AHK script

^+!F4::
Run, taskkill.exe
/F /FI "status eq NOT RESPONDING"
/FI "IMAGENAME ne AltSnap.exe"
/FI "IMAGENAME ne dwm.exe"
/FI "IMAGENAME ne explorer.exe"
,,hide

^ = Ctrl
+ = Shift
! = Alt
,,hide = Don't show cmd window

@RamonUnch
Copy link
Owner

I will link this topic in the wiki and present your .ahk script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants