public static void Init() { #if USE_MOUSE_IN_PLACE_OF_TOUCH touchHook = new WM_MouseHook(BokuGame.bokuGame.Window.Handle); #else IntPtr mainformHandle = MainForm.Instance.Handle; IntPtr xnaControlHandle = XNAControl.Instance.Handle; cwTouchHook = new WM_TouchHook(xnaControlHandle, TouchHook.HookType.WH_CALLWNDPROC); //messageTouchHook = new WM_TouchHook(BokuGame.bokuGame.Window.Handle, TouchHook.HookType.WH_GETMESSAGE); #endif WM_TouchHook.DisableNativePressAndHoldGesture = true; //messageTouchHook.InstallHook(); cwTouchHook.InstallHook(); #if USE_MOUSE_IN_PLACE_OF_TOUCH touchHook.MouseDown += new EventHandler <MouseEventArgs>(MouseDownHandler); touchHook.MouseMove += new EventHandler <MouseEventArgs>(MouseMoveHandler); touchHook.MouseUp += new EventHandler <MouseEventArgs>(MouseUpHandler); #else cwTouchHook.TouchDown += new EventHandler <TouchEventArgs>(TouchDownHandler); cwTouchHook.TouchMove += new EventHandler <TouchEventArgs>(TouchMoveHandler); cwTouchHook.TouchUp += new EventHandler <TouchEventArgs>(TouchUpHandler); //messageTouchHook.TouchDown += new EventHandler<TouchEventArgs>(TouchDownHandler); //messageTouchHook.TouchMove += new EventHandler<TouchEventArgs>(TouchMoveHandler); //messageTouchHook.TouchUp += new EventHandler<TouchEventArgs>(TouchUpHandler); //store the max touch count detected at startup TouchInput.TouchAvailable = cwTouchHook.IsTouchAvailable(); TouchInput.MaxTouchCount = cwTouchHook.GetMaxTouches(); #endif }
public Form1() { InitializeComponent(); var proc = Process.Start($@"C:\Work\Shortcuts\AngryBirdsSpace.exe.lnk"); mh = new WM_MouseHook(proc.MainWindowHandle); mh.MouseDown += Mh_MouseDown; mh.InstallHook(); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { var proc = Process.Start($@"C:\Work\Shortcuts\AngryBirdsSpace.exe.lnk"); await Task.Delay(1000); _hwnd = Process.GetCurrentProcess().MainWindowHandle; mh = new WM_MouseHook(_hwnd); mh.InstallHook(); mh.MouseDown += Mh_MouseDown; mh.MouseMove += delegate { }; }