我借用了一些将密钥事件发送到另一个进程(hWnd)的代码。以下是该功能的定义:
public static void SendKey(ushort key, IntPtr hWnd)
{
SetActiveWindow(hWnd);
SendMessage(hWnd, WM_KEYDOWN, key, 0);
SendMessage(hWnd, WM_KEYUP, key, 0);
}
从DllImport获取SendMessage:
//sends a windows message to the specified window
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, uint wParam, int lParam);
如您所见,SendKey方法为要发送的密钥采用 ushort 值。
有谁知道我在哪里可以找到这些值?即如果用户按下“7”键并且我想转发它如何从7键事件/回调转到ushort值?
谢谢!