-
Notifications
You must be signed in to change notification settings - Fork 0
/
mute_ads.cpp
142 lines (125 loc) · 2.78 KB
/
mute_ads.cpp
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include <windows.h>
#include <iostream>
using namespace std;
int flag = 0;
int codeMuted = 0;
string ell = " ...", holder;
void roll()
{
int i = ell.find(' ');
ell[i] = '.';
ell[(i+1)%4] = ' ';
}
void nudgeVolume()
{
WORD arr[] = {VK_VOLUME_UP, VK_VOLUME_DOWN};
for (int t=0; t<2; t++)
{
INPUT ip={0};
ip.type = INPUT_KEYBOARD;
ip.ki.wVk = arr[t]; //or VOLUME_DOWN or MUTE
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
}
}
void muteVolume()
{
nudgeVolume();
INPUT ip={0};
ip.type = INPUT_KEYBOARD;
ip.ki.wVk = VK_VOLUME_MUTE;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
}
bool isPresent(string str, string str1)
{
size_t found = str.find(str1);
if (found != string::npos)
return true;
return false;
}
string convertToString(char* a, int size)
{
int i;
string s = "";
for (i = 0; i < size; i++) {
s = s + a[i];
}
return s;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
if(IsWindowVisible(hwnd)) // check whether window is visible
{
char wnd_title[256];
GetWindowText(hwnd,wnd_title,sizeof(wnd_title));
string title = convertToString(wnd_title, sizeof(wnd_title)/sizeof(char));
if (isPresent(title, "Advertisement"))
flag = 1;
}
return true; // function must return true if you want to continue enumeration
}
void check()
{
EnumWindows(EnumWindowsProc,0);
}
int barvar = 0;
unsigned char barchar[2] = {219, 176};
void prt_bar(int i = barvar, int steps = 117)
{
cout<<'\r';
if (barvar>=steps)
{
barvar = barvar % steps;
unsigned char t = barchar[0];
barchar[0] = barchar[1];
barchar[1] = t;
}
cout<<'|';
for (int i = 0; i < steps; i++)
if (i <= barvar)
cout<<barchar[0];
else
cout<<barchar[1];
cout<<'|';
barvar += 1;
}
void prtClr(int n)
{
for (int i = 0; i < n; i++)
cout<<' ';
}
int main()
{
system("Color 02");
SetConsoleTitle("Running");
while (true)
{
flag = 0;
check();
if (flag == 1 && codeMuted == 0)
{
muteVolume();
codeMuted = 1;
system("Color 4E");
cout<<"\rMuted";
prtClr(114);
SetConsoleTitle("Muted");
cout<<endl;
}
else if (flag == 0 && codeMuted == 1)
{
nudgeVolume();
codeMuted = 0;
system("Color 02");
cout<<"\rUnmuted";
prtClr(112);
SetConsoleTitle("Running");
cout<<endl;
}
prt_bar();
Sleep(100);
}
}