I want to simulate multiple keypress -like (Shift+UP) or the scroll of the mouse- on my gesture-application.
This is my KeyPressEmulator
class
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 );
}
}
}
And this is the main window witch call the google earth processes
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;
}
}
}
For example: 0x22 simulate the 'previeus page' and zone on google earth.
so if i want the simulate 'Shift+UP' or 'the scroll of the mouse' how can i do this?