马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
该工具类似火绒的弹窗拦截,拦截的弹窗数据完全由用户决定,比如某个弹窗出现了以后你就可以使用该软件把这个弹窗信息添加进去,下次这个弹窗就会被拦截掉;
使用过程中会在同目录下生成一个rules.data的文件,这里面存储的就是拦截的弹窗规则
使用说明:
1.CTRL+ALT+E 将鼠标放到需要关闭的弹窗上(尽量放在弹窗边缘上)按下该快捷键即可将这个弹窗加入拦截列表;
2.CTRL+ALT+T 显示或者隐藏该工具的窗口,如果要退出拦截可关闭该窗口或者进程即可。
源码:
- #include <afxwin.h>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <thread>
- #define RULE_FILE "rules.data"
- using namespace std;
- HWND hWnd;
- string wndtitle;
- BOOL showflag = false;
- bool Init();
- void GetWnd(HWND& wnd, string& title);
- void WriteRules(string rule);
- bool IsHit(string title);
- void FindAd();
- void ShowHide();
- BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
- int main()
- {
- SetWindowTextA(GetForegroundWindow(),"Panel AD Killer made by Panel www.52pojie.cn");
- if (!Init())
- {
- return 0;
- }
- HANDLE hThread;
- hThread = CreateThread(
- NULL,
- 0,
- (LPTHREAD_START_ROUTINE)FindAd,
- NULL,
- 0,
- NULL);
- // 消息循环
- MSG msg = { 0 };
- while (GetMessage(&msg, NULL, 0, 0) != 0) {
- if (msg.wParam == 1) {
- GetWnd(hWnd, wndtitle);
- WriteRules(wndtitle);
- }if (msg.wParam == 2)
- {
- ShowHide();
- }
- if (msg.message == WM_CLOSE) {
- ShowWindow(hWnd, SW_HIDE);
- }
- }
- }
- bool Init()
- {
- BOOL flag;
- if (RegisterHotKey(NULL, 1, MOD_CONTROL | MOD_ALT, 'E')) {
- cout << "初始化成功1\n";
- flag = true;
- }
- else {
- cout << "初始化失败,热键可能被占用1\n";
- flag = false;
- }
- if (RegisterHotKey(NULL, 2, MOD_CONTROL | MOD_ALT, 'T')) {
- cout << "初始化成功2\n";
- flag = true;
- }
- else {
- cout << "初始化失败,热键可能被占用2\n";
- flag = false;
- }
- return flag;
- }
- void GetWnd(HWND& wnd, string& title)
- {
- POINT pNow = { 0,0 };
- if (GetCursorPos(&pNow))
- {
- HWND hwndPointNow = NULL;
- hwndPointNow = WindowFromPoint(pNow);
- wnd = hwndPointNow;
- if (hwndPointNow)
- {
- char szWindowTitle[50];
- ::GetWindowTextA(hwndPointNow, szWindowTitle, sizeof(szWindowTitle));
- title = string(szWindowTitle);
- //cout << hex << (int)hwndPointNow << endl;
- cout << szWindowTitle << endl;
- }
- else
- cout << "Error!!" << endl;
- }
- }
- void WriteRules(string rule)
- {
- ofstream file(RULE_FILE,ios::binary|ios::app);
- if (!file.is_open()) {
- std::cerr << "配置文件无法打开" << std::endl;
- return;
- }
- file << rule << std::endl;
- file.close();
- }
- bool IsHit(string title)
- {
- ifstream inputFile(RULE_FILE,ios::app);
- if (!inputFile.is_open()) {
- std::cerr << "无法打开文件" << std::endl;
- return false; // 返回错误代码
- }
- std::string line;
- while (std::getline(inputFile, line)) {
- if (line == title)
- {
- inputFile.close();
- return true;
- }
- }
- return false;
- }
- void FindAd()
- {
- do
- {
- EnumWindows(EnumWindowsProc, 0); Sleep(1000);
- } while (true);
- }
- void ShowHide()
- {
- showflag = !showflag;
- if (showflag)
- {
- ShowWindow(GetForegroundWindow(), SW_HIDE);
- }
- else {
- ShowWindow(GetForegroundWindow(), SW_SHOW);
- }
- }
- BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) {
- char windowTitle[256];
- GetWindowTextA(hwnd, windowTitle, sizeof(windowTitle));
- if (string(windowTitle) == "")
- {
- return true;
- }
- if (string(windowTitle).find("shadow") != string::npos)
- {
- PostMessage(hwnd, WM_CLOSE, 0, 0);
- }
- if (IsHit(string(windowTitle)))
- {
- PostMessage(hwnd, WM_CLOSE, 0, 0);
- }
- return TRUE; // 继续列举下一个窗口
- }
复制代码 防止倒卖,加了vmp的壳,下载地址:直接点我下载
|