关闭ShowDialog的模态窗口
[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的模态窗口的更多相关文章
- 使用jQuery和Bootstrap实现多层、自适应模态窗口
本篇实践一个多层模态窗口,而且是自适应的. 点击页面上的一个按钮,弹出第一层自适应模态窗口. 在第一层模态窗口内包含一个按钮,点击该按钮弹出第二层模态窗口,弹出的第二层模态窗口会挡住第一层模态窗口,即 ...
- c# 定时关闭 MessageBox 或弹出的模态窗口
我们都知道,MessageBox弹出的窗口是模式窗口,模式窗口会自动阻塞父线程的.所以如果有以下代码: MessageBox.Show("内容',"标题"); 则只有关闭 ...
- 2019-6-23-WPF-解决弹出模态窗口关闭后,主窗口不在最前
title author date CreateTime categories WPF 解决弹出模态窗口关闭后,主窗口不在最前 lindexi 2019-06-23 11:48:38 +0800 20 ...
- WPF 解决弹出模态窗口关闭后,主窗口不在最前
本文告诉大家如何解决这个问题,在 WPF 的软件,弹出一个模态窗口.使用另一个窗口在模态窗口前面.从任务栏打开模态窗口.关闭模态窗口.这时发现,主窗口会在刚才使用的另一个窗口下面 这是 Windows ...
- 用JqueryUI的Dialog+IFrame实现仿模态窗口效果
大家有没有想过这样一个问题,当我点击某个图片的时候,我想弹出这个图片信息的详情并修改,于是你首先想到的是不是window.open?window.open方法确实可以,但是有它的局限性,比如,标题显示 ...
- 15款最好的 jQuery Modal(模态窗口)插件
jQuery 模态窗口插件帮助网站开发人员显示网页中的特定内容,让用户聚焦到这个地方.模态窗口是嵌入到当前网页中,不用重定向到新网页的弹出窗口.这种技术可以用在图像画廊,电子商务网站,登陆框,电子邮件 ...
- Swift-打开其它Storyboard中的自定义模态窗口
本文的方法针对OS X应用开发. 如果想在某个ViewController中,用模态窗口的方式,打开某个Storyboard中定义的WindowController.可用以下方式. let story ...
- JS 弹出模态窗口解决方案
最近在项目中使用弹出模态窗口,功能要求: (1)模态窗口选择项目 (2)支持选择返回事件处理 在IE中有showModalDialog 方法,可以很好的解决该问题,但是在Chrome中和FF中就有问题 ...
- 十、ios 模态窗口[实例]
一.模态窗口概念 对话框一般分为两种类型:模态类型( modal )与非模态类型( modeless ).所谓模态对话框,就是指除非采取有效的关闭手段,用户的鼠标焦点或者输入光标将一直停留在其上的对话 ...
随机推荐
- xss payload大全
刚好刚才在fuzz一个站的时候用到,就从笔记里抛出来了. code: (1)普通的XSS JavaScript注入 <SCRIPT SRC=http://3w.org/XSS/xss.js> ...
- Flutter Form正确使用方法【可正确获取提交的表单数据】
import 'package:flutter/material.dart'; void main() => runApp(new HomePage()); class HomePage ext ...
- Linux记录-centos升级python3
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel -yyum install xz -ywget https://www.p ...
- Python - Django - ORM 多对多表结构的三种方式
多对多的三种方式: ORM 自动创建第三张表 自己创建第三张表, 利用外键分别关联作者和书,关联查询比较麻烦,因为没办法使用 ORM 提供的便利方法 自己创建第三张表,使用 ORM 的 ManyToM ...
- [转载] HashMap的工作原理-hashcode和equals的区别
目录 前言 为什么需要使用Hashcode,可以从Java集合的常用需求来描述: 更深入的介绍 先来些简单的问题 HashMap的0.75负载因子 总结 我在网上看到的这篇文章,介绍的很不错,但是我看 ...
- Golang中的Map(集合)
Map 是一种无序的键值对的集合.Map 最重要的一点是通过 key 来快速检索数据,key 类似于索引,指向数据的值. Map 是一种集合,所以我们可以像迭代数组和切片那样迭代它.不过,Map 是无 ...
- ubuntu18.04安装golang
首先我们通过如下命令安装golang: sudo add-apt-repository ppa:longsleep/golang-backports sudo apt-get update sudo ...
- 【Leetcode_easy】965. Univalued Binary Tree
problem 965. Univalued Binary Tree 参考 1. Leetcode_easy_965. Univalued Binary Tree; 完
- 【转载】我为什么放弃了 Linux 内核学习?
最近学习内核很是心累,碰巧看到这篇文章,有点意思~ 转自http://happypeter.github.io/index.html,以下为原文内容: 我在国内的技术类网站 / 博客上, 时常会看到分 ...
- Appium移动自动化测试-----(四)安装 appium Server
我们可以在Appium官方网站上下载操作系统相应的Appium版本. https://bitbucket.org/appium/appium.app/downloads/ 当前最新版本为 Appium ...