如何使用Windows消息保持ALT鍵?使用Windows消息保持Alt鍵
是否有WM_KEYHOLD或類似的東西?
這是屏幕截圖的代碼,但我猜想一些東西是想念。我認爲我使用的關鍵代碼是不好的,對於0x70,它發送F1。併爲0x46它發送anoyying窗口聲音。
const uint WM_SYSKEYDOWN = 260;
const uint VK_MENU = 18;//virtual key code of Alt key
const uint VK_SNAPSHOT = 44;//virtual key code of Snapshot key
[DllImport("User32.Dll")]
public static extern long PostMessage(IntPtr hWnd, UInt32 wMsg, long wParam, long lParam);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(String sClassName, String sAppName);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetForegroundWindow();
private void timer1_Tick(object sender, EventArgs e)
{
IntPtr hwnd = GetForegroundWindow();
//PostMessage(hwnd, WM_SYSKEYDOWN, VK_MENU, 1);
PostMessage(hwnd, WM_SYSKEYDOWN, VK_SNAPSHOT, 1);
}
這是隻爲你的應用程序,或者你想發送到整個系統? – 2011-06-07 15:46:46