[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string a, string b); [DllImport("user32.dll")]
private static extern IntPtr PostMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
   Timer timer = new Timer();
timer.Tick += (obj, arg) =>
{
//1、尝试关闭ColorDialog
IntPtr ptr1 = FindWindow(null, "颜色");
if (ptr1 != IntPtr.Zero)
{
PostMessage(ptr1, 0x0010, IntPtr.Zero, IntPtr.Zero);
SetInfoBar("ColorDialog已关闭");
}
//2、尝试关闭FolderBrowserDialog
IntPtr ptr2 = FindWindow(null, "浏览文件夹");
if (ptr2 != IntPtr.Zero)
{
PostMessage(ptr2, 0x0010, IntPtr.Zero, IntPtr.Zero);
SetInfoBar("FolderBrowserDialog已关闭");
}
//3、尝试关闭FontDialog
IntPtr ptr3 = FindWindow(null, "字体");
if (ptr3 != IntPtr.Zero)
{
PostMessage(ptr3, 0x0010, IntPtr.Zero, IntPtr.Zero);
SetInfoBar("FontDialog已关闭");
}
//4、尝试关闭OpenFileDialog
IntPtr ptr4 = FindWindow(null, "打开");
if (ptr4 != IntPtr.Zero)
{
PostMessage(ptr4, 0x0010, IntPtr.Zero, IntPtr.Zero);
SetInfoBar("OpenFileDialog已关闭");
}
//5、尝试关闭SaveFileDialog
IntPtr ptr5 = FindWindow(null, "另存为");
if (ptr5 != IntPtr.Zero)
{
PostMessage(ptr5, 0x0010, IntPtr.Zero, IntPtr.Zero);
SetInfoBar("SaveFileDialog已关闭");
}
//6、尝试关闭MessageBox
IntPtr ptr6 = FindWindow(null, "测试消息");
if (ptr6 != IntPtr.Zero)
{
PostMessage(ptr6, 0x0010, IntPtr.Zero, IntPtr.Zero);
SetInfoBar("MessageBox已关闭");
}
//7、尝试关闭自定义窗口(Show)
IntPtr ptr7 = FindWindow(null, "自定义窗口(Show)");
if (ptr7 != IntPtr.Zero)
{
PostMessage(ptr7, 0x0010, IntPtr.Zero, IntPtr.Zero);
SetInfoBar("自定义窗口(Show)已关闭");
}
//8、尝试关闭自定义窗口(ShowDialog)
IntPtr ptr8 = FindWindow(null, "自定义窗口(ShowDialog)");
if (ptr8 != IntPtr.Zero)
{
PostMessage(ptr8, 0x0010, IntPtr.Zero, IntPtr.Zero);
SetInfoBar("自定义窗口(ShowDialog)已关闭");
}
};
timer.Interval = 5000;
timer.Enabled = true;
timer.Start();

关闭ShowDialog的模态窗口的更多相关文章

  1. 使用jQuery和Bootstrap实现多层、自适应模态窗口

    本篇实践一个多层模态窗口,而且是自适应的. 点击页面上的一个按钮,弹出第一层自适应模态窗口. 在第一层模态窗口内包含一个按钮,点击该按钮弹出第二层模态窗口,弹出的第二层模态窗口会挡住第一层模态窗口,即 ...

  2. c# 定时关闭 MessageBox 或弹出的模态窗口

    我们都知道,MessageBox弹出的窗口是模式窗口,模式窗口会自动阻塞父线程的.所以如果有以下代码: MessageBox.Show("内容',"标题"); 则只有关闭 ...

  3. 2019-6-23-WPF-解决弹出模态窗口关闭后,主窗口不在最前

    title author date CreateTime categories WPF 解决弹出模态窗口关闭后,主窗口不在最前 lindexi 2019-06-23 11:48:38 +0800 20 ...

  4. WPF 解决弹出模态窗口关闭后,主窗口不在最前

    本文告诉大家如何解决这个问题,在 WPF 的软件,弹出一个模态窗口.使用另一个窗口在模态窗口前面.从任务栏打开模态窗口.关闭模态窗口.这时发现,主窗口会在刚才使用的另一个窗口下面 这是 Windows ...

  5. 用JqueryUI的Dialog+IFrame实现仿模态窗口效果

    大家有没有想过这样一个问题,当我点击某个图片的时候,我想弹出这个图片信息的详情并修改,于是你首先想到的是不是window.open?window.open方法确实可以,但是有它的局限性,比如,标题显示 ...

  6. 15款最好的 jQuery Modal(模态窗口)插件

    jQuery 模态窗口插件帮助网站开发人员显示网页中的特定内容,让用户聚焦到这个地方.模态窗口是嵌入到当前网页中,不用重定向到新网页的弹出窗口.这种技术可以用在图像画廊,电子商务网站,登陆框,电子邮件 ...

  7. Swift-打开其它Storyboard中的自定义模态窗口

    本文的方法针对OS X应用开发. 如果想在某个ViewController中,用模态窗口的方式,打开某个Storyboard中定义的WindowController.可用以下方式. let story ...

  8. JS 弹出模态窗口解决方案

    最近在项目中使用弹出模态窗口,功能要求: (1)模态窗口选择项目 (2)支持选择返回事件处理 在IE中有showModalDialog 方法,可以很好的解决该问题,但是在Chrome中和FF中就有问题 ...

  9. 十、ios 模态窗口[实例]

    一.模态窗口概念 对话框一般分为两种类型:模态类型( modal )与非模态类型( modeless ).所谓模态对话框,就是指除非采取有效的关闭手段,用户的鼠标焦点或者输入光标将一直停留在其上的对话 ...

随机推荐

  1. 为什么说基于TCP的移动端IM仍然需要心跳保活?(转)

    源:https://segmentfault.com/a/1190000006832547 为什么说基于TCP的移动端IM仍然需要心跳保活?

  2. mailgun php 邮件发送 实例

    步骤如下: 通过 composer 获取代码库 获取 API Key 以及 domain 编写代码发送邮件 1. 首先通过 composer 获取依赖代码库,参考官网给的命令 https://docu ...

  3. nginx多层反向代理获取客户端真实ip

    访问路径: 用户 --> www.chinasoft.cn(nginx反向代理) --> www.chinasoft.com(nginx反向代理) --> python服务端程序 经 ...

  4. 深入学习c++--多线程编程(一)

    1. 简介 2. 线程使用 2.1 demo #include <iostream> #include <thread> #include <future> usi ...

  5. Spring cloud微服务安全实战-3-5 API安全机制之认证(2)

    基于Http协议的认证方式有很多.本节我们只讲一个最简单的HttpBasic认证.聪明就可以看出来,这是一个最基础的认证,好处是简单方便,所有的主流浏览器都支持,问题就是并不是非常安全的,但是帮我们大 ...

  6. LeetCode_219. Contains Duplicate II

    219. Contains Duplicate II Easy Given an array of integers and an integer k, find out whether there ...

  7. PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'exchange' in vhost '/': received 'direct

    最近在搞rabbitmq,把解决问题方法记下 问题1:PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'exchange' in ...

  8. jenkins集成robot用例并发送自定义报告

    slave

  9. C++ 三大特性 继承(转载)

    继承 继承:类的继承,就是新的类从已有类那里得到已有的特性.原有的类称为基类或父类,产生的新类称为派生类或子类. 基本语法 派生类的声明: class 派生类名:继承方式 基类名1, 继承方式 基类名 ...

  10. linux vi指令常用

    1:退出时提示:No write since last change (add ! to override):解决方法:直接ctrl + z退出