如何使用Windows消息按住ALT按钮?
是否有WM_KEYHOLD或类似内容?
这是屏幕截图的代码,但我想有些东西是错过的。我认为使用的密钥代码是坏的,对于0x70,它发送F1。对于0x46,它会发出令人不快的窗口声音。
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);
}