Exemple #1
0
        public static void KeyUp(KB kb)
        {
            User.Struct.INPUT input = new User.Struct.INPUT(User.Const.INPUT_KEYBOARD);
            input.ki.dwExtraInfo = User.GetMessageExtraInfo();

            // Key down shift, ctrl, and/or alt
            input.ki.dwFlags = User.Const.KEYEVENTF_KEYUP;

            if ((kb & KB.KB_SHIFT) == KB.KB_SHIFT)
            {
                input.ki.wVk = (ushort)User.VK.VK_SHIFT;
                SendInput(input);
            }
            if ((kb & KB.KB_CONTROL) == KB.KB_CONTROL)
            {
                input.ki.wVk = (ushort)User.VK.VK_CONTROL;
                SendInput(input);
            }
            if ((kb & KB.KB_ALT) == KB.KB_ALT)
            {
                input.ki.wVk = (ushort)User.VK.VK_MENU;
                SendInput(input);
            }
            if ((kb & KB.KB_WIN) == KB.KB_WIN)
            {
                input.ki.wVk = (ushort)User.VK.VK_LWIN;
                SendInput(input);
            }
        }
Exemple #2
0
 public static void SendInputMouse(uint flags, int x, int y)
 {
     // SendInput doesn't perform click mouse button unless I move cursor  http://stackoverflow.com/questions/8021954/sendinput-doesnt-perform-click-mouse-button-unless-i-move-cursor
     User.Struct.INPUT input = new User.Struct.INPUT();
     input.type           = User.Const.INPUT_MOUSE;
     input.mi.dx          = x;
     input.mi.dy          = y;
     input.mi.dwFlags     = flags; //MOUSEEVENTF_ABSOLUTE, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP
     input.mi.mouseData   = 0;
     input.mi.dwExtraInfo = IntPtr.Zero;
     input.mi.time        = 0;
     Windows.SendInput(input);
 }
Exemple #3
0
        public static void KeyboardEvent(char c, KB kb)
        {
            User.Struct.INPUT input = new User.Struct.INPUT(User.Const.INPUT_KEYBOARD);
            input.ki.dwExtraInfo = User.GetMessageExtraInfo();

            KeyDown(kb);

            input.ki.wVk     = 0;
            input.ki.wScan   = c;
            input.ki.dwFlags = User.Const.KEYEVENTF_UNICODE;
            SendInput(input);

            input.ki.dwFlags = User.Const.KEYEVENTF_UNICODE | User.Const.KEYEVENTF_KEYUP;
            SendInput(input);

            KeyUp(kb);
        }
Exemple #4
0
        public static void KeyboardEvent(User.VK vk, KB kb)
        {
            User.Struct.INPUT input = new User.Struct.INPUT(User.Const.INPUT_KEYBOARD);
            input.ki.dwExtraInfo = User.GetMessageExtraInfo();

            KeyDown(kb);

            // Key down the actual key-code
            input.ki.wVk = (ushort)vk;
            SendInput(input);

            // Key up the actual key-code
            input.ki.dwFlags = User.Const.KEYEVENTF_KEYUP;
            SendInput(input);

            KeyUp(kb);
        }
Exemple #5
0
        public static void MouseEvent(int x, int y, params uint[] mouseEvents)
        {
            GetAbsoluteCoordinates(ref x, ref y);

            User.Struct.INPUT input = new User.Struct.INPUT(User.Const.INPUT_MOUSE);
            //User_struct.INPUT[] input = new User_struct.INPUT[1];
            //input[0] = new User_struct.INPUT();
            input.type           = User.Const.INPUT_MOUSE;
            input.mi.dx          = x;
            input.mi.dy          = y;
            input.mi.mouseData   = 0;
            input.mi.time        = 0;
            input.mi.dwExtraInfo = User.GetMessageExtraInfo();

            foreach (uint mouseEvent in mouseEvents)
            {
                input.mi.dwFlags = mouseEvent;
                //User.SendInput(1, ref input, Marshal.SizeOf(input));
                //User.SendInput(1, input, Marshal.SizeOf(input));
                SendInput(input);
            }
        }
Exemple #6
0
        public static void KeyUp(KB kb)
        {
            User.Struct.INPUT input = new User.Struct.INPUT(User.Const.INPUT_KEYBOARD);
            input.ki.dwExtraInfo = User.GetMessageExtraInfo();

            // Key down shift, ctrl, and/or alt
            input.ki.dwFlags = User.Const.KEYEVENTF_KEYUP;

            if ((kb & KB.KB_SHIFT) == KB.KB_SHIFT)
            {
                input.ki.wVk = (ushort)User.VK.VK_SHIFT;
                SendInput(input);
            }
            if ((kb & KB.KB_CONTROL) == KB.KB_CONTROL)
            {
                input.ki.wVk = (ushort)User.VK.VK_CONTROL;
                SendInput(input);
            }
            if ((kb & KB.KB_ALT) == KB.KB_ALT)
            {
                input.ki.wVk = (ushort)User.VK.VK_MENU;
                SendInput(input);
            }
            if ((kb & KB.KB_WIN) == KB.KB_WIN)
            {
                input.ki.wVk = (ushort)User.VK.VK_LWIN;
                SendInput(input);
            }
        }
Exemple #7
0
        public static void KeyboardEvent(string s, KB kb)
        {
            User.Struct.INPUT input = new User.Struct.INPUT(User.Const.INPUT_KEYBOARD);
            input.ki.dwExtraInfo = User.GetMessageExtraInfo();

            KeyDown(kb);

            foreach (char c in s)
            {
                input.ki.wVk = 0;
                input.ki.wScan = c;
                input.ki.dwFlags = User.Const.KEYEVENTF_UNICODE;
                SendInput(input);

                input.ki.dwFlags = User.Const.KEYEVENTF_UNICODE | User.Const.KEYEVENTF_KEYUP;
                SendInput(input);
            }

            KeyUp(kb);
        }
Exemple #8
0
        public static void KeyboardEvent(User.VK vk, KB kb)
        {
            User.Struct.INPUT input = new User.Struct.INPUT(User.Const.INPUT_KEYBOARD);
            input.ki.dwExtraInfo = User.GetMessageExtraInfo();

            KeyDown(kb);

            // Key down the actual key-code
            input.ki.wVk = (ushort)vk;
            SendInput(input);

            // Key up the actual key-code
            input.ki.dwFlags = User.Const.KEYEVENTF_KEYUP;
            SendInput(input);

            KeyUp(kb);
        }
Exemple #9
0
        public static void MouseEvent(int x, int y, params uint[] mouseEvents)
        {
            GetAbsoluteCoordinates(ref x, ref y);

            User.Struct.INPUT input = new User.Struct.INPUT(User.Const.INPUT_MOUSE);
            //User_struct.INPUT[] input = new User_struct.INPUT[1];
            //input[0] = new User_struct.INPUT();
            input.type = User.Const.INPUT_MOUSE;
            input.mi.dx = x;
            input.mi.dy = y;
            input.mi.mouseData = 0;
            input.mi.time = 0;
            input.mi.dwExtraInfo = User.GetMessageExtraInfo();

            foreach (uint mouseEvent in mouseEvents)
            {
                input.mi.dwFlags = mouseEvent;
                //User.SendInput(1, ref input, Marshal.SizeOf(input));
                //User.SendInput(1, input, Marshal.SizeOf(input));
                SendInput(input);
            }
        }
Exemple #10
0
 public static void SendInput(User.Struct.INPUT input)
 {
     User.Struct.INPUT[] inputs = new User.Struct.INPUT[1];
     inputs[0] = input;
     User.SendInput(1, inputs, Marshal.SizeOf(input));
 }
Exemple #11
0
 public static void SendInput(User.Struct.INPUT input)
 {
     User.Struct.INPUT[] inputs = new User.Struct.INPUT[1];
     inputs[0] = input;
     User.SendInput(1, inputs, Marshal.SizeOf(input));
 }
Exemple #12
0
 public static void SendInputMouse(uint flags, int x, int y)
 {
     // SendInput doesn't perform click mouse button unless I move cursor  http://stackoverflow.com/questions/8021954/sendinput-doesnt-perform-click-mouse-button-unless-i-move-cursor
     User.Struct.INPUT input = new User.Struct.INPUT();
     input.type = User.Const.INPUT_MOUSE;
     input.mi.dx = x;
     input.mi.dy = y;
     input.mi.dwFlags = flags; //MOUSEEVENTF_ABSOLUTE, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP
     input.mi.mouseData = 0;
     input.mi.dwExtraInfo = IntPtr.Zero;
     input.mi.time = 0;
     Windows.SendInput(input);
 }