C 利用钩子控制鼠标【月儿原创】

分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

               

C#利用钩子控制鼠标

作者:清清月儿

主页:http://blog.csdn.net/21aspnet/           时间:2007.5.11

工作中有这样的需求,某个控件panel的子控件textbox要实现只留鼠标右键copy,注意同时还不能影响其它panel的子控件textbox,怎么办?
答案是只有用钩子,在codeporject上找到这么一个钩子。

如图所示,第一个文本框只有copy功能。


UserActivityHook.cs


using  System;
using  System.Runtime.InteropServices;
using  System.Reflection;
using  System.Threading;
using  System.Windows.Forms;
using  System.ComponentModel;

namespace  gma.System.Windows
... {
 /**//// <summary>
 /// This class allows you to tap keyboard and mouse and / or to detect their activity even when an 
 /// application runes in background or does not have any user interface at all. This class raises 
 /// common .NET events with KeyEventArgs and MouseEventArgs so you can easily retrieve any information you need.
 /// </summary>

 public class UserActivityHook
 ...{
  Windows structure definitions#region Windows structure definitions

  /**//// <summary>
  /// The POINT structure defines the x- and y- coordinates of a point. 
  /// </summary>
  /// <remarks>
  /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/rectangl_0tiq.asp
  /// </remarks>

  [StructLayout(LayoutKind.Sequential)]
   private class POINT
  ...{
   /**//// <summary>
   /// Specifies the x-coordinate of the point. 
   /// </summary>

   public int x;
   /**//// <summary>
   /// Specifies the y-coordinate of the point. 
   /// </summary>

   public int y;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值