Example #1
0
        public static void SendKey(VK key)
        {
            SetForegroundWindow(Form1.m_captureProcess.Process.MainWindowHandle);

            INPUT2[] input = new INPUT2[] {
                new INPUT2()
                {
                    type = InputType.INPUT_KEYBOARD,
                    ki   = new KEYBDINPUT {
                        wVk         = 0,
                        wScan       = ScanCode.F5,
                        dwFlags     = KEYEVENTF.KEYEVENTF_SCANCODE,
                        dwExtraInfo = null,
                        time        = 0
                    }
                },
                new INPUT2()
                {
                    type = InputType.INPUT_KEYBOARD,
                    ki   = new KEYBDINPUT {
                        wVk         = 0,
                        wScan       = ScanCode.F5,
                        dwFlags     = KEYEVENTF.KEYEVENTF_SCANCODE | KEYEVENTF.KEYEVENTF_KEYUP,
                        dwExtraInfo = null,
                        time        = 0
                    }
                }
            };

            SendInput(input.Length, input, Marshal.SizeOf(typeof(INPUT)));
        }
Example #2
0
        public static void SendMouseLButtonDown(Point pos)
        {
            Point AbsolutePos = GetAbsPos(pos);

            SetForegroundWindow(Form1.m_captureProcess.Process.MainWindowHandle);

            INPUT2[] input = new INPUT2[] {
                new INPUT2()
                {
                    type = InputType.INPUT_MOUSE,
                    mi   = new MOUSEINPUT {
                        dx          = AbsolutePos.X,
                        dy          = AbsolutePos.Y,
                        dwFlags     = (MOUSEEVENTF.MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF.MOUSEEVENTF_VIRTUALDESK | MOUSEEVENTF.MOUSEEVENTF_MOVE | MOUSEEVENTF.MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF.MOUSEEVENTF_LEFTUP),
                        mouseData   = 0,
                        dwExtraInfo = null,
                        time        = 0
                    }
                }
            };

            SendInput(input.Length, input, Marshal.SizeOf(typeof(INPUT)));
        }