c#des?

来源:互联网 发布:大数据分析模型和方法 编辑:程序博客网 时间:2024/05/20 10:15

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Rohan
{
    class Program
    {
    
           [DllImport("User32.dll",EntryPoint="SendMessage")]  
              private   static   extern   int   SendMessage(  
                                          int   hWnd,             //   handle   to   destination   window  
                                          int   Msg,               //   message  
                                          int   wParam,       //   first   message   parameter  
                                          string   lParam         //   second   message   parameter  
                );  
              [DllImport("User32.dll",EntryPoint="FindWindow")]  
              private   static   extern   int   FindWindow(string   lpClassName,string  
  lpWindowName);

 


              [DllImport("user32.dll", SetLastError = true)]
              static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

         
              //定义消息常数  
              const int WM_GETTEXT = 0x000D;
              const int WM_SETTEXT = 0x000C;
              const int WM_CLICK = 0x00F5;
              const int WM_SHOWDROPDOWN = 0x014D;//在窗体中声明消息常量
              const int WM_SETCURSOR = 0x14F;
              const int CB_FINDSTRING = 0x14C;
              const int WM_LBUTTONDBLCLK = 0x203;//双击鼠标左键

 

 


        static void Main(string[] args)
        {
            /*
            string str = "NGSNLL";
            int WINDOW_HANDLER = FindWindow(null, @"无标题 - 记事本");
            if (WINDOW_HANDLER == 0)
            {
                throw new Exception("Could   not   find   Main   window!");
            }
            SendMessage(WINDOW_HANDLER, WM_SETTEXT, 0,str);
             */


            IntPtr WINDOW_HANDLER =new IntPtr(FindWindow(null, @"计算器"));
            IntPtr buttonhwnd = FindWindowEx(WINDOW_HANDLER, IntPtr.Zero, "Button", "C");

          int c;
          //SendMessage(int.Parse(buttonhwnd), WM_LBUTTONDBLCLK, 0, null);

 

           
      
              
        }
    }
}

原创粉丝点击