毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> net技术 >> 正文

怎样使用C#.net去解决远程控制别机鼠标

更新时间:2012-7-4:  来源:毕业论文

怎样使用C#.net去解决远程控制别机鼠标//
有案例的请借用下。。
急用///// <summary>
  /// API类
  /// </summary>
  public class Api
  {
  /// <summary>
  /// 模拟鼠标事件的函数模型
  /// </summary>
  /// <param name="flags"></param>
  /// <param name="dx"></param>
  /// <param name="dy"></param>
  /// <param name="dwData"></param>
  /// <param name="dwExtraInfo"></param>
  [DllImport("user32.dll", CharSet = CharSet.Auto)]
  public static extern void mouse_event(int flags, int dx, int dy, int dwData, int dwExtraInfo);

  /// <summary>
  /// 设置光标到指定位置的函数模型
  /// </summary>
  /// <param name="X"></param>
  /// <param name="Y"></param>
  /// <returns></returns>
  [DllImport("user32.dll", CharSet = CharSet.Auto)]
  public static extern bool SetCursorPos(int X, int Y);

  /// <summary>
  /// 模拟键盘事件的函数模型
  /// </summary>
  /// <param name="bVk"></param>
  /// <param name="bScan"></param>
  /// <param name="dwFlags"></param>
  /// <param name="dwExtraInfo"></param>
  [DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "keybd_event")]
  public static extern void keybd_event(
  byte bVk,
  byte bScan,
  int dwFlags,
  int dwExtraInfo
  );
  }

  /// <summary>
  /// 鼠标Hook类
  /// </summary>
  public class MouseHook
  {  
  /// <summary>
  /// 鼠标事件枚举
  /// </summary>
  public enum MouseEventFlag
  {
  Move = 0x0001,
  LeftDown = 0x0002,
  LeftUp = 0x0004,
  RightDown = 0x0008,
  RightUp = 0x0010,
  MiddleDown = 0x0020,
  MiddleUp = 0x0040,
  XDown = 0x0080,
  XUp = 0x0100,
  Wheel = 0x0800,
  VirtualDesk = 0x4000,
  Absolute = 0x8000
  }
  /// <summary>
  /// 委托-鼠标按键触发
  /// </summary>
  /// <param name="flags"></param>
  /// <param name="dx"></param>
  /// <param name="dy"></param>
  /// <param name="dwData"></param>
  /// <param name="dwExtraInfo"></param>
  public delegate void DoMouseButtons(int flags, int dx, int dy, int dwData, int dwExtraInfo);
  /// <summary>
  /// 委托-鼠标移动触发
  /// </summary>
  /// <param name="X"></param>
  /// <param name="Y"></param>
  /// <returns></returns>
  public delegate bool DoMouseMove(int X, int Y);
  /// <summary>
  /// 模拟鼠标按钮按下的事件
  /// </summary>
  private event DoMouseButtons MouseButton;
  /// <summary>
  /// 模拟鼠标移动的事件
  /// </summary>
  private event DoMouseMove MouseMove;

  /// <summary>
  /// 创建鼠标钩子的实例
  /// </summary>
  public MouseHook()
  {
  MouseButton += new DoMouseButtons(Api.mouse_event);
  MouseMove += new DoMouseMove(Api.SetCursorPos);
  }

  /// <summary>
  /// 控制鼠标执行相应操作
  /// </summary>
  /// <param name="MEvent">指定的鼠标事件</param>
  public void MouseWork(MouseEvent MEvent)
  {

  switch (MEvent.Type)
  {
  case MouseEventType.MouseMove:
  MouseMove(MEvent.X, MEvent.Y);
  break;
  case MouseEventType.MouseLeftDown:
  MouseMove(MEvent.X, MEvent.Y);
  MouseButton((int)MouseEventFlag.LeftDown, MEvent.X, MEvent.Y, 0, 0);
  break;
  case MouseEventType.MouseLeftUp:

[1] [2] 下一页

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。