分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!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;
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;