sendkey
我曾经用这个发送键盘消息达到泡泡的自动回复功能

解决方案 »

  1.   

    模拟鼠标键盘要用hook?hook用来截取消息的比较多一些鼠标:mouse_event
    键盘:keydb_event
      

  2.   

    给你个简单的鼠标模拟参考参考
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace Example107_模拟鼠标
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.button1 = new System.Windows.Forms.Button();
    this.SuspendLayout();
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(144, 176);
    this.button1.Name = "button1";
    this.button1.TabIndex = 0;
    this.button1.Text = "Mouse";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(280, 237);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.button1});
    this.Name = "Form1";
    this.Text = "Form1";
    this.DoubleClick += new System.EventHandler(this.Form1_DoubleClick);
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private System.Windows.Forms.Button button1; [System.Runtime.InteropServices.DllImport("user32")]
    private static extern int mouse_event(int dwFlags,int dx,int dy, int cButtons, int dwExtraInfo);
    const int MOUSEEVENTF_MOVE = 0x0001;
    const int MOUSEEVENTF_LEFTDOWN = 0x0002;
    const int MOUSEEVENTF_LEFTUP = 0x0004;
    const int MOUSEEVENTF_RIGHTDOWN = 0x0008;
    const int MOUSEEVENTF_RIGHTUP = 0x0010;
    const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
    const int MOUSEEVENTF_MIDDLEUP = 0x0040;
    const int MOUSEEVENTF_ABSOLUTE = 0x8000; private void Form1_DoubleClick(object sender, System.EventArgs e)
    {
    MessageBox.Show("Double Click");
    } private void button1_Click(object sender, System.EventArgs e)
    {
    mouse_event(MOUSEEVENTF_MOVE,-10,-10,0,0);
    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
    }
    }
    }
      

  3.   

    不用最低层的,其他的不知道啦。DirectX的话,找红星星!一个字----------求,也许他们帮你写一个。hohoho
      

  4.   

    private void button1_Click(object sender, System.EventArgs e)
    {
    char strWindow;
    IntPtr hParent = IntPtr.Zero;
    IntPtr hNext=IntPtr.Zero;
    timer1.Enabled=false;
    string sClassName = "TestSendKey"; //要关闭的窗口标题
    hNext=NativeWIN32.FindWindowEx(hParent,hNext,IntPtr.Zero,sClassName);
    if(hNext.ToInt32()>0)
    {
    NativeWIN32.SetForegroundWindow(hNext.ToInt32());//置顶显示
    NativeWIN32.ShowWindow(hNext.ToInt32(),NativeWIN32.nCmdShow.SW_SHOWMINNOACTIVE); //显示窗口

        System.Windows.Forms.SendKeys.Send("%{F4}");//要发送的值,这个是发 ALT+F4,具体其他的看帮助


    }
    }
    }
    public class NativeWIN32
    {
    [DllImport("user32.dll", CharSet=CharSet.Auto)]
    public static extern IntPtr FindWindowEx(IntPtr parent /*HWND*/, 
    IntPtr next /*HWND*/, 
    IntPtr sClassName,  
    string sWindowTitle);
    [DllImport("user32.dll", CharSet=CharSet.Auto)]
    public static extern void SetForegroundWindow(int hwnd); [DllImport("user32.dll")]
    public static extern bool ShowWindow(int hWnd, nCmdShow nCmdShow); [DllImport("user32.dll", CharSet=CharSet.Auto)]
    public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam); //SendMessage(Handle2, WM_GETTEXT, 1024, Integer(@Buf)); public enum nCmdShow:uint
    {
    SW_FORCEMINIMIZE=0x0,
    SW_HIDE=0x1,
    SW_MAXIMIZE=0x2,
    SW_MINIMIZE=0x3,
    SW_RESTORE=0x4,
    SW_SHOW=0x5,
    SW_SHOWDEFAULT=0x6,
    SW_SHOWMAXIMIZED=0x7,
    SW_SHOWMINIMIZED=0x8,
    SW_SHOWMINNOACTIVE=0x9,
    SW_SHOWNA=0xA,
    SW_SHOWNOACTIVATE=0xB,
    SW_SHOWNORMAL=0xC,
    WM_CLOSE=0x10,
    } }