• 被某弹窗弄烦了实现自动关闭弹窗


    RT,的确是有点儿烦人,写了个Daemon

    修改配置文件中"CalcFrame,计算器",格式:"ClassName,标题",可以那spyxx抓下:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
                <section name="PopKiller.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
            </sectionGroup>
        </configSections>
        <applicationSettings>
            <PopKiller.Settings>
                <setting name="ClassWindowName" serializeAs="Xml">
                    <value>
                        <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                            <string>CalcFrame,计算器</string>
                            <string>TXGuiFoundation,腾讯网新闻</string>
                        </ArrayOfString>
                    </value>
                </setting>
            </PopKiller.Settings>
        </applicationSettings>
    </configuration>

    代码简单得很,大家参考,[PopKiller.7z]

    using System;
    using System.Runtime.InteropServices;
    using System.Timers;
    
    namespace PopKiller
    {
        class Program
        {
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            static extern IntPtr FindWindow(string className, string windowName);
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
    
            const uint WM_CLOSE = 0x0010;
            static System.Timers.Timer timer1;
            static System.Collections.Specialized.StringCollection lstClassWindowName;
    
            static void Main(string[] args)
            {
                lstClassWindowName = Settings.Default.ClassWindowName;
                timer1 = new Timer();
                timer1.Elapsed += new ElapsedEventHandler(timer1_Elapsed);
                timer1.Start();
                GC.KeepAlive(timer1);
                while (true)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
    
            static void timer1_Elapsed(object sender, ElapsedEventArgs e)
            {
                foreach (var item in lstClassWindowName)
                {
                    IntPtr hwnd = FindWindow(item.Split(',')[0], item.Split(',')[1]);
                    if (hwnd != IntPtr.Zero)
                    {
                        SendMessage(hwnd, WM_CLOSE, 0, 0);
                        //System.Diagnostics.Debug.WriteLine("Closed " + item);
                    }
                }
            }
        }
    }
  • 相关阅读:
    MVVM教程[资源+分析]
    WPF 多点触摸开发[1]:Windows 7 安装多点触屏模拟器
    wpf 打印 之PirintVisual
    WPF:PrintVisual的问题
    几个漂亮的Button的CSS
    很不错的后台界面收集[提供下载]
    网页刷新方法集合
    JS各种各样的拖动效果
    CSS+DIV(盒子)
    网页刷新方法集合
  • 原文地址:https://www.cnblogs.com/eshizhan/p/2652136.html
Copyright © 2020-2023  润新知