点击别的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. todo bitnami

    https://bitnami.com/stack/dokuwiki https://bitnami.com/stack/jenkins/installer

  2. 【19.46%】【codeforces 551B】ZgukistringZ

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 如何去掉windows2003的自动锁定(每离开一会都会出现这个界面,不想让它出现)

    http://zhidao.baidu.com/link?url=SOCv57C-hX_3f0Xl0J0RFIVXpowXk73zdQd2B-wMUzYOm5E_N397bw_UkX4uLPlAiWQ ...

  4. [React Router v4] Render Nested Routes

    With React Router v4 the entire library is built as a series of React components. That means that cr ...

  5. asp.net core2.0 部署centos7/linux系统 --守护进程supervisor(二)

    原文:asp.net core2.0 部署centos7/linux系统 --守护进程supervisor(二) 续上一篇文章:asp.net core2.0 部署centos7/linux系统 -- ...

  6. Linux中的zip与scp

    现在只是学会基本操作,不深究各个参数的含义 一般操作目录时,都有一个-r代表递归操作整个目录下的所有内容 压缩一个目录test到test.zip zip -r test test.zip 解压test ...

  7. html5--6-33 CSS定位是什么

    html5--6-33 CSS定位是什么 一.总结 一句话总结: 1.常规文档流是一套体系,浮动是另外一套体系. 2.标签清除浮动之后会跑到常规文档流它本来的地方. 3.浮动是否占据常规文档流:应该不 ...

  8. 二维高斯滤波器(gauss filter)的实现

    我们以一个二维矩阵表示二元高斯滤波器,显然此二维矩阵的具体形式仅于其形状(shape)有关: def gauss_filter(kernel_shape): 为实现二维高斯滤波器,需要首先定义二元高斯 ...

  9. DYNAMIC CONTEXT SWITCHING BETWEEN ARCHITECTURALLY DISTINCT GRAPHICS PROCESSORS

    FIELD OF INVENTION This invention relates to computer graphics processing, and more specifically to ...

  10. jQuery Media Plugin 现在插上实线的视频播放服务

    jQuery Media 一个简短的引论 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvWGluZ0tvbmcyMnN0YXI=/font/5a6L5L2T ...