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);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, IntPtr windowTitle);
//定义消息常数
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);
*/
int WINDOW_HANDLER = FindWindow(null, @"计算器");
int buttonhwnd = FindWindowEx(WINDOW_HANDLER, IntPtr.Zero, "C", "Button");
SendMessage(buttonhwnd,WM_LBUTTONDBLCLK, 0, null);
}
}
}