我有以下代码:

    public static void Next()
    {
        Process[] processes = Process.GetProcessesByName("test");

        foreach (Process proc in processes)
            PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_RIGHT, 0);
    }

这段代码发送了向右箭头键,我想发送ALT + CTRL + RIGHT,我尝试过这样:
    public static void Forward()
    {
        Process[] processes = Process.GetProcessesByName("test");

        foreach (Process proc in processes)
        {
            PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_CONTROL, 0);
            PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_ALT, 0);
            PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_RIGHT, 0);
        }
    }

但这行不通...
有任何想法吗?

最佳答案

You can't simulate keyboard input with PostMessage,至少不能可靠地使用SendInput

关于c# - PostMessage WM_KEYDOWN发送多个 key ?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7732633/

10-12 21:25