zoukankan      html  css  js  c++  java
  • C#查找某一窗口并按钮

    using System.Runtime.InteropServices;

    [DllImport(
    "user32.dll", EntryPoint = "FindWindow", 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);

    const uint BM_CLICK = 0xF5;

    IntPtr msgHandle 
    = FindWindow(null"Form1");
    if (msgHandle != IntPtr.Zero)
    {
        
    //找到Button
        IntPtr btnHandle = FindWindowEx(msgHandle, 0"Button""确定");
        
    if (btnHandle != IntPtr.Zero)
        {
            SendMessage(btnHandle, BM_CLICK, 
    00);
        }
    }
  • 相关阅读:
    转:SkipList跳表
    git操作
    JAVA小工具打包
    Java数字证书操作
    mysql创建数据库和用户
    解决node-sass安装不了的问题
    vscode + angular
    ng2 quickstart-primeng
    ng2 quickstart
    使用淘宝的npm代理下载模块
  • 原文地址:https://www.cnblogs.com/mobydick/p/1753797.html
Copyright © 2011-2022 走看看