Exemplo n.º 1
0
        public static void MouseSend(int x, int y, Input.MouseFlag flag, int data)
        {
            INPUT[] input = new INPUT[1];
            int value = (int)flag;
            if (flag == Input.MouseFlag.MoveTo)
            {
                value = ((int)(MOUSEEVENTF_ABSOLUTE) | (int)(MOUSEEVENTF_MOVE));
                x = 65536 * x / W;
                y = 65536 * y / H;
            }
            if (flag == Input.MouseFlag.AddTo)
            {
                x = 65536 * x / W;
                y = 65536 * y / H;
            }
            input[0] = new INPUT();
            input[0].mi.dx = x;
            input[0].mi.dy = y;
            input[0].mi.dwExtraInfo = (IntPtr)0;
            input[0].mi.time = 0;
            input[0].mi.mouseData = data;

            input[0].mi.dwFlags = value;
            input[0].type = INPUT_MOUSE;
            SendInput(1, input, Marshal.SizeOf(input[0]));
        }
Exemplo n.º 2
0
 public static void MouseSend(int x, int y, Input.MouseFlag flag, int data)
 {
     INPUT[] input = new INPUT[1];
     input[0] = new INPUT();
     input[0].mi.dx = x;
     input[0].mi.dy = y;
     input[0].mi.dwExtraInfo = (IntPtr)0;
     input[0].mi.time = 0;
     input[0].mi.mouseData = data;
     input[0].mi.dwFlags = (int)flag;
     input[0].type = INPUT_MOUSE;
     SendInput(1, input, Marshal.SizeOf(input[0]));
 }
Exemplo n.º 3
0
 public static void KeySend(int key, Input.KeyFlag flag)
 {
     INPUT[] input = new INPUT[2];
     input[0] = new INPUT();
     input[1] = new INPUT();
     input[0].type = input[1].type = INPUT_KEYBOARD;
     input[0].ki.wVk = input[1].ki.wVk = (short)key;
     short scan = (short)MapVirtualKey((uint)key, 0);
     input[0].ki.wScan = scan;
     input[1].ki.wScan = (short)(scan + 128);
     input[0].ki.dwFlags = KEYEVENTF_SCANCODE;
     input[1].ki.dwFlags = KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE;
     switch (key)
     {
         case 37:
         case 38:
         case 39:
         case 40:
             input[0].ki.dwFlags |= 1;
             input[1].ki.dwFlags |= 1;
             break;
     }
     switch ((int)flag)
     {
         case 0:
             SendInput(1, input, Marshal.SizeOf(input[0]));
             break;
         case 1:
             input[0] = input[1];
             SendInput(1, input, Marshal.SizeOf(input[0]));
             break;
         case 2:
             SendInput(2, input, Marshal.SizeOf(input[0]));
             break;
     }
 }