读书人

想用windows API 实现alt+a键的组合按

发布时间: 2012-02-25 10:01:48 作者: rapoo

想用windows API 实现alt+a键的组合按键,不知道怎么实现,请高手指点
急!!!


[解决办法]
BOOL RegisterHotKey( HWND hWnd,
int id,
UINT fsModifiers,
UINT vk
);

public enum KeyModifiers
{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8
}

[DllImport("user32.dll", SetLastError=true)]
public static extern bool RegisterHotKey(IntPtr hWnd, // handle to window
int id, // hot key identifier
KeyModifiers fsModifiers, // key-modifier options
Keys vk // virtual-key code
);

RegisterHotKey(Handle, 94, KeyModifiers.Alt, Keys.A);

读书人网 >C#

热点推荐