C#如何在失去焦点时也能使用快捷键
来源:百度知道 编辑:UC知道 时间:2024/05/28 03:04:35
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Collections;
namespace HotKey1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public delegate void HotkeyEventHandler(int HotKeyID);
private int Hotkey1;
public class Hotkey : System.Windows.Forms.IMessageFilter
{
Hashtable keyIDs = new Hashtable();
IntPtr hWnd;
public event HotkeyEventHandler OnHotkey;
public enum KeyFlags
{
MOD_ALT = 0x1,
MOD_CONTROL = 0x2,
MOD_SHIFT = 0x4,
MOD_WIN = 0x8
}
[DllImport("user32.dll")]
public static extern UInt32 RegisterHotKey(IntPtr hWnd, UInt32 id, UInt32 fsModifiers, UInt32 vk);