You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.3 KiB
37 lines
1.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Container.Common
|
|
{
|
|
public class Win32Api
|
|
{
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public class POINT
|
|
{
|
|
public int x;
|
|
public int y;
|
|
}
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public class MouseHookStruct
|
|
{
|
|
public POINT pt;
|
|
public int hwnd;
|
|
public int wHitTestCode;
|
|
public int dwExtraInfo;
|
|
}
|
|
public delegate int HookProc(int nCode, IntPtr wParam, IntPtr lParam);
|
|
//安装钩子
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
|
|
//卸载钩子
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
public static extern bool UnhookWindowsHookEx(int idHook);
|
|
//调用下一个钩子
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
public static extern int CallNextHookEx(int idHook, int nCode, IntPtr wParam, IntPtr lParam);
|
|
}
|
|
}
|
|
|