-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRespondingGuy.cpp
More file actions
92 lines (79 loc) · 2.54 KB
/
Copy pathRespondingGuy.cpp
File metadata and controls
92 lines (79 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "RespondingGuy.h"
#include <tlhelp32.h>
#include <psapi.h>
#include <string>
#pragma comment(lib, "psapi.lib")
static HANDLE g_killerThread = NULL;
static bool g_isResponding = false;
HWND FindNotRespondingDialog() {
HWND hWnd = FindWindow(NULL, L"Konata Dancer");
if (hWnd) {
wchar_t title[256];
GetWindowText(hWnd, title, 256);
if (wcsstr(title, L"Not Responding") || wcsstr(title, L"Íå îòâå÷àåò")) {
return hWnd;
}
}
hWnd = FindWindow(L"#32770", NULL);
if (hWnd) {
wchar_t title[256];
GetWindowText(hWnd, title, 256);
if (wcsstr(title, L"Not Responding") || wcsstr(title, L"Íå îòâå÷àåò")) {
return hWnd;
}
}
return NULL;
}
void AutoClickCloseButton() {
for (int attempt = 0; attempt < 30; attempt++) {
HWND hDialog = FindNotRespondingDialog();
if (hDialog) {
HWND hButton = FindWindowEx(hDialog, NULL, L"Button", L"Close the program");
if (!hButton) hButton = FindWindowEx(hDialog, NULL, L"Button", L"Çàêðûòü ïðîãðàììó");
if (!hButton) hButton = FindWindowEx(hDialog, NULL, L"Button", L"Close program");
if (!hButton) hButton = FindWindowEx(hDialog, NULL, L"Button", L"Close");
if (!hButton) hButton = FindWindowEx(hDialog, NULL, L"Button", L"Çàêðûòü");
if (hButton) {
SetForegroundWindow(hDialog);
SendMessage(hButton, BM_CLICK, 0, 0);
return;
}
}
Sleep(500);
}
}
DWORD WINAPI KillerThreadProc(LPVOID lpParam) {
Sleep(500);
AutoClickCloseButton();
Sleep(1000);
TerminateProcess(GetCurrentProcess(), 0);
return 0;
}
void DontRespond(HWND hwnd) {
if (g_isResponding) return;
g_isResponding = true;
if (hwnd && IsWindow(hwnd)) {
ShowWindow(hwnd, SW_SHOW);
SetForegroundWindow(hwnd);
BringWindowToTop(hwnd);
SetWindowText(hwnd, L"Konata Dancer (Not Responding)");
SetClassLongPtr(hwnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor(NULL, IDC_WAIT));
UpdateWindow(hwnd);
RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW);
KillTimer(hwnd, 1);
}
g_killerThread = CreateThread(NULL, 0, KillerThreadProc, NULL, 0, NULL);
while (true) {
Sleep(INFINITE);
}
}
void SelfDestruct() {
TerminateProcess(GetCurrentProcess(), 0);
}
void CleanupRespondingGuy() {
if (g_killerThread) {
CloseHandle(g_killerThread);
g_killerThread = NULL;
}
g_isResponding = false;
}