C# 模拟多按键的问题

C# 模拟多按键的问题,c#,kinect,simulation,kinect-sdk,C#,Kinect,Simulation,Kinect Sdk,我想在我的手势应用程序上模拟多个按键(Shift+UP)或鼠标滚动 这是我的KeyPressEmulator课程 static class KeyPressEmulator { const UInt32 WM_KEYDOWN = 0x0100; const UInt32 WM_KEYUP = 0x0101; [DllImport("user32.dll")] static extern bool PostMessage(IntPtr hWnd, UInt32 M

我想在我的手势应用程序上模拟多个按键(Shift+UP)或鼠标滚动

这是我的
KeyPressEmulator
课程

static class KeyPressEmulator
{
    const UInt32 WM_KEYDOWN = 0x0100;
    const UInt32 WM_KEYUP = 0x0101;

    [DllImport("user32.dll")]
    static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);

    [STAThread]
    public static void setKeyPressed(int key, Boolean pressed)
    {
        Process[] processes = Process.GetProcessesByName("googleearth");

        foreach (Process proc in processes)
        {
            PostMessage(proc.MainWindowHandle, pressed ? WM_KEYDOWN : WM_KEYUP, key,0 );
        }

    }
}
这是谷歌地球进程的主窗口

private void sensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
    Skeleton first = GetFirstSkeleton(e);
    Dictionary<BaseGesture, int> gestures = new Dictionary<BaseGesture, int>();
    gestures.Add(new HandsOut(), 0x22);
    gestures.Add(new HandsIn(), 0x21);
    gestures.Add(new PanUp(), 0x58);
    gestures.Add(new PanDown(), 0x43);
    gestures.Add(new PanLeft(), 0x42);
    gestures.Add(new PanRight(), 0x56);

    foreach (BaseGesture gesture in gestures.Keys)
        KeyPressEmulator.setKeyPressed(gestures[gesture], false);

    foreach (BaseGesture gesture in gestures.Keys)
    {
        if (gesture.CheckGesture(first) == GestureResult.Success)
        {
            KeyPressEmulator.setKeyPressed(gestures[gesture], true);
            break;
        }
    }
}
private void sensor_allframesrady(对象发送器,allframesradyeventargs e)
{
骨架优先=GetFirstSkeleton(e);
字典手势=新字典();
添加(新的handout(),0x22);
添加(新的HandsIn(),0x21);
添加(新的PanUp(),0x58);
添加(新的PanDown(),0x43);
添加(新的PanLeft(),0x42);
添加(新的PanRight(),0x56);
foreach(手势中的基本手势。键)
KeyPressEmulator.setKeyPressed(手势[手势],false);
foreach(手势中的基本手势。键)
{
if(手势。检查手势(第一个)=手势结果。成功)
{
KeyPressEmulator.setKeyPressed(手势[手势],真);
打破
}
}
}
例如:0x22在google earth上模拟“预览页面”和区域


因此,如果我想要模拟“Shift+UP”或“鼠标滚动”,我该怎么做呢?

试试多线程。创建多线程,以便可以一次发送多个密钥

    DWORD WINAPI Send_Key2(LPVOID lParam)
{
//code
//code
return NULL;
}

CreateThread(0,0x1000,&Send_Key2,NULL,0,NULL);
//untested

我正在尝试做类似的事情,你能回答吗?