我試圖打印字母「a」從我的應用程序的活動窗口:SendMessage函數不起作用從C#
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
...
// global hotkey handler
void hook_KeyPressed(object sender, KeyPressedEventArgs e)
{
var hWnd = GetForegroundWindow();
SendMessage(hWnd, (uint)WM.KEYDOWN, (int)VK.KEY_A, 0);
SendMessage(hWnd, (uint)WM.KEYUP, (int)VK.KEY_A, 0);
}
但是信沒有出現在活動窗口(任何應用程序)。有誰能夠幫助我?
感謝您的回覆。我發現了[DllImport(「user32.dll」)] public static extern void keybd_event(byte bVk,byte bScan,uint dwFlags,uint dwExtraInfo); – 2011-01-24 08:50:29