点击别的winform窗口的按钮

        #region 点击别的窗口的按钮
[DllImport("user32.dll", EntryPoint = "FindWindowA", SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, uint hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hwnd, uint wMsg, int wParam, int lParam); [DllImport("user32.dll", EntryPoint = "SetForegroundWindow", SetLastError = true)]
private static extern void SetForegroundWindow(IntPtr hwnd);
public static void ClickOtherWindowsBtn(string targetWindowsTitile ,string btnText)
{
try
{ const int WM_CLICK = 0x00F5;//鼠标点击消息,各种消息的数值,可以参考MSDN IntPtr hwndTestChild = new IntPtr();//子窗体的句柄
IntPtr hwndbtnYes = new IntPtr();//子窗体上button的句柄 hwndTestChild = FindWindow(null, targetWindowsTitile);//获取子窗体的句柄
hwndbtnYes = FindWindowEx(hwndTestChild, , null, btnText);//获取子窗体上button的句柄 if (hwndTestChild != IntPtr.Zero)
{
SendMessage(hwndbtnYes, WM_CLICK, , );//给子窗体上button发送鼠标点击消息,
}
else
{
Console.WriteLine("没有找到按钮");
} }
catch (System.Exception ex)
{
Console.WriteLine(ex.ToString());
}
} #endregion

win32Helper的更多相关文章

  1. 更新整理本人所有博文中提供的代码与工具(C++,2014.01)

    为了更方便地管理博文中涉及的各种代码与工具资源,现在把这些资源迁移到 Google Code 中,有兴趣者可前往下载. C++ 1.<通用高性能 Windows Socket 组件 HP-Soc ...

  2. 更新整理本人所有博文中提供的代码与工具(C++,2013.11)

    为了更方便地管理博文中涉及的各种代码与工具资源,现在把这些资源迁移到 Google Code 中,有兴趣者可前往下载. C++ 1.<通用高性能 Windows Socket 组件 HP-Soc ...

  3. 更新整理本人所有博文中提供的代码与工具(C++,2013.10)

    为了更方便地管理博文中涉及的各种代码与工具资源,现在把这些资源迁移到 Google Code 中,有兴趣者可前往下载. C++ 1.<通用高性能 Windows Socket 组件 HP-Soc ...

  4. 更新整理本人所有博文中提供的代码与工具(C++,2013.08)

    为了更方便地管理博文中涉及的各种代码与工具资源,现在把这些资源迁移到 Google Code 中,有兴趣者可前往下载. C++ 1.<通用高性能 Windows Socket 组件 HP-Soc ...

  5. 更新代码和工具,组织起来,提供所有博文(C++,2014.09)

    为了更容易地管理各种规范和工具所涉及的资源鲍文,现在把这些资源迁移 GitHub 在,趣者可前往下载. C++ 1.<通用高性能 Windows Socket 组件 HP-Socket v3.2 ...

  6. C#取色器

    闲来无事,就写了一个取色器.原理其实很简单,只需要两步, 获取鼠标光标的位置, 获取当前鼠标光标的位置的RGB颜色值. 获取鼠标光标的位置: System.Drawing.Point p = Mous ...

  7. C# 结合 PInvoke 对接 IP 摄像头的笔记

    最近做项目的时候,需要对接厂商提供的 IP 摄像头.但是他们只提供了 C++ 的 SDK,没办法,只能开始撸 C# 的 SDK Helper 类.本篇文章主要记录了对接 C++ DLL 需要注意的几个 ...

  8. C#修改电脑桌面图

    win32helper public class Win32Helper { [DllImport("user32.dll", EntryPoint = "SystemP ...

  9. C#选择文件返回缩略图

    传入文件路径,返回临时文件中缩略图的路径,jpg,pdf,office,rar都行 string path = ThumbnailHelper.GetInstance().GetJPGThumbnai ...

随机推荐

  1. 小强的HTML5移动开发之路(47)——jquery mobile基本的页面框架

    一.单容器页面结构 <!DOCTYPE html> <html> <head> <title>Jquery mobile 基本页面框架</titl ...

  2. Ubuntu安装编译OpenCV一键脚本(带ffmpeg)

    1.切换到用户文件夹 cd ~ 2.新建一个文件.命名为opencv.sh 脚本例如以下: version="$(wget -q -O - http://sourceforge.net/pr ...

  3. jQuery+ localStorage 实现一个简易的计时器

    原型 图片发自简书App 需求1.关闭浏览器时时间继续运行2.刷新时保持当前状态3.结束时间保存在客户端 <div class="wrapper"> <div c ...

  4. python 多进程与多线程配合拷贝文件目录

    版本一:使用shutil进行拷贝 # -*- coding: utf-8 -*- # @author: Tele # @Time : 2019/04/02 下午 3:09 # 待改进: # 1.拷贝逻 ...

  5. java使用mongoDB和freemarker注意事项

    mongoDB和关系数据库的差异最大的优势就是表结构不正确,说:.弱事务.mongoDB以牺牲换来的交易进行更快的访问速度,有人说mongoDB对于内存太贪婪,事实上,它不会.随着windows版本, ...

  6. Zepto.js touch,tap增加 touch模块深入分析

    1. touch库实现了什么和引入背景 click事件在移动端上会有 300ms 的延迟,同时因为需要 长按 , 双触击 等富交互,所以我们通常都会引入类似 zepto 这样的库.zepto 中tou ...

  7. hadoop 3.x 集群/单个节点的启动与停止

    1.单个节点操作 启动|停止单个节点 hdfs --daemon start|stop datanode hdfs --daemon start|stop namenode 启动|停止单个节点的Nod ...

  8. 商(quotient)—— 两数之比

    1. IQ:Intelligence quotient IQ=MACA×100 MA:心智年龄(mental age) CA:实足年龄(chronological age)

  9. js 如何一次性删除数组中的多个元素

    用for循环或者forEach遍历数组的话,在方法体内部splice都得不到正确的结果.有什么好的办法解决这个问题吗? var arr=[2,3,5,7]; arr.forEach(function( ...

  10. 【16.52%】【codeforces 733C】Epidemic in Monstropolis

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...