예제 #1
0
        private static void ClickOnPoint(IntPtr wndHandle, Point clientPoint, KeyCommandType command)
        {
            uint buttonDown, buttonUp = 0;

            if (command == KeyCommandType.LeftClick)
            {
                buttonDown = User32Dll.MOUSEEVENTF_LEFTDOWN;
                buttonUp   = User32Dll.MOUSEEVENTF_LEFTUP;
            }
            else if (command == KeyCommandType.RightClick)
            {
                buttonDown = User32Dll.MOUSEEVENTF_RIGHTDOWN;
                buttonUp   = User32Dll.MOUSEEVENTF_RIGHTUP;
            }
            else
            {
                return;
            }

            var oldPos = Cursor.Position;

            /// get screen coordinates
            User32Dll.ClientToScreen(wndHandle, ref clientPoint);

            /// set cursor on coords, and press mouse
            Cursor.Position = new Point(clientPoint.X, clientPoint.Y);
            User32Dll.mouse_event(buttonDown, 0, 0, 0, UIntPtr.Zero);
            User32Dll.mouse_event(buttonUp, 0, 0, 0, UIntPtr.Zero);

            /// return mouse
            Cursor.Position = oldPos;
        }
예제 #2
0
        public void ProcessKeyCommand(KeyCommandType command, string customCommand = "")
        {
            User32Dll.ShowWindowAsync(hWnd, User32Dll.SW_SHOW);
            switch (command)
            {
            case KeyCommandType.Escape:
                SendKeys.SendWait("{ESC}");
                break;

            case KeyCommandType.Key_W:
                SendKeys.SendWait("wwwwwwwwww");
                break;

            case KeyCommandType.Key_A:
                SendKeys.SendWait("aaaaaaaaaa");
                break;

            case KeyCommandType.Key_S:
                SendKeys.SendWait("ssssssssss");
                break;

            case KeyCommandType.Key_D:
                SendKeys.SendWait("dddddddddd");
                break;

            case KeyCommandType.LeftClick:
                break;

            case KeyCommandType.RightClick:
                break;

            case KeyCommandType.LookUp:
                break;

            case KeyCommandType.LookDown:
                break;

            case KeyCommandType.LookLeft:
                break;

            case KeyCommandType.LookRight:
                break;

            case KeyCommandType.Custom:
                break;
            }
        }