Example #1
0
 private static void OnPlayerChat(Int32 sender, String message, ChatRecipients recipients)
 {
     try
     {
         if (InternalInput.PlayerChat != null)
         {
             InternalInput.PlayerChat(sender, message, recipients);
         }
     }
     catch (Exception e)
     {
         Trace.WriteLine("Unhandled Exception in InternalInput.OnPlayerChat!");
         Trace.WriteLine(e.ToString());
     }
 }
Example #2
0
        private static IntPtr CGameUI__DisplayChatMessageHook(CGameUI _this, Int32 sender, String message, ChatRecipients recipients, Single duration)
        {
            try
            {
                InternalInput.OnPlayerChat(sender, message, recipients);

                if (InternalInput.BlockChat)
                {
                    return(IntPtr.Zero);
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Unhandled Exception in InternalInput.CGameUI__DisplayChatMessageHook!");
                Trace.WriteLine(e.ToString());
            }

            return(CGameUI__DisplayChatMessage(_this, sender, message, recipients, duration));
        }
Example #3
0
        private static IntPtr WndProcHook(IntPtr hWnd, UInt32 msg, UInt32 wParam, UInt32 lParam)
        {
            try
            {
                switch ((WindowsMessage)msg)
                {
                case WindowsMessage.KeyDown:
                    // only proceed if the 30th bit of lParam is 0 because that means the key wasn't down until now
                    if ((((lParam >> 30) & 1) == 0))
                    {
                        InternalInput.OnKeyboardKey((Int32)wParam, (Char)wParam, KeyboardKeyState.Down);
                    }
                    break;

                case WindowsMessage.KeyUp:
                    InternalInput.OnKeyboardKey((Int32)wParam, (Char)wParam, KeyboardKeyState.Up);
                    break;

                case WindowsMessage.Char:
                    InternalInput.OnKeyboardKey((Int32)wParam, (Char)wParam, KeyboardKeyState.Char);
                    break;

                case WindowsMessage.MouseMove:
                    InternalInput.MouseWindow = new Point2(LOWORD(lParam), HIWORD(lParam));
                    break;

                case WindowsMessage.LeftButtonDown:
                    InternalInput.OnMouseButton(MouseButton.Left, MouseButtonState.Down, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    break;

                case WindowsMessage.LeftButtonUp:
                    InternalInput.OnMouseButton(MouseButton.Left, MouseButtonState.Up, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    break;

                case WindowsMessage.LeftButtonDoubleClick:
                    // This doesn't appear to happen.
                    break;

                case WindowsMessage.RightButtonDown:
                    InternalInput.OnMouseButton(MouseButton.Right, MouseButtonState.Down, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    break;

                case WindowsMessage.RightButtonUp:
                    InternalInput.OnMouseButton(MouseButton.Right, MouseButtonState.Up, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    break;

                case WindowsMessage.RightButtonDoubleClick:
                    // This doesn't appear to happen.
                    break;

                case WindowsMessage.MiddleButtonDown:
                    InternalInput.OnMouseButton(MouseButton.Middle, MouseButtonState.Down, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    break;

                case WindowsMessage.MiddleButtonUp:
                    InternalInput.OnMouseButton(MouseButton.Middle, MouseButtonState.Up, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    break;

                case WindowsMessage.MiddleButtonDoubleClick:
                    // This doesn't appear to happen.
                    break;

                case WindowsMessage.ExtraButtonDown:
                    if (HIWORD(wParam) == 1)
                    {
                        InternalInput.OnMouseButton(MouseButton.X1, MouseButtonState.Down, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    }
                    if (HIWORD(wParam) == 2)
                    {
                        InternalInput.OnMouseButton(MouseButton.X2, MouseButtonState.Down, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    }
                    break;

                case WindowsMessage.ExtraButtonUp:
                    if (HIWORD(wParam) == 1)
                    {
                        InternalInput.OnMouseButton(MouseButton.X1, MouseButtonState.Up, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    }
                    if (HIWORD(wParam) == 2)
                    {
                        InternalInput.OnMouseButton(MouseButton.X2, MouseButtonState.Up, new Point2(LOWORD(lParam), HIWORD(lParam)));
                    }
                    break;

                case WindowsMessage.ExtraButtonDoubleClick:
                    // This doesn't appear to happen.
                    break;

                case WindowsMessage.MouseWheel:
                    InternalInput.OnMouseWheel(HIWORD(wParam));
                    break;

                default:
                    // The following are the only other messages detected.
                    // It's possible we can detect more if we hook war3.exe's wndproc.
                    // WM_SETCURSOR: 0x0020
                    // WM_GETICON:   0x007F
                    // WM_NCHITTEST: 0x0084
                    break;
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Unhandled Exception in InternalInput.WndProcHook!");
                Trace.WriteLine(e.ToString());
            }

            return(WndProc(hWnd, msg, wParam, lParam));
        }