Exemplo n.º 1
0
        public static void SendK(IntPtr wnd, Char ch, Int32 delayMs)
        {
            ushort       temp       = (ushort)User32.VkKeyScan(ch);
            byte         vkCode     = (byte)(0xFF & temp);
            byte         comboState = (byte)(temp >> 8);
            extraKeyInfo lParam     = new extraKeyInfo();

            lParam.scanCode = (char)User32.MapVirtualKey(vkCode, User32.MAPVK_VK_TO_VSC);
            if (IsShift(comboState))
            {
                var array = new byte[256];
                User32.GetKeyboardState(array);
                array[VK_SHIFT] = 1; // shift
                User32.SetKeyboardState(array);
                PressShift(wnd);
            }
            User32.PostMessage(wnd, User32.WM_KEYDOWN, (IntPtr)vkCode, (UIntPtr)lParam.getint());
            lParam.repeatCount     = 1;
            lParam.prevKeyState    = 1;
            lParam.transitionState = 1;
            if (delayMs > 0)
            {
                System.Threading.Thread.Sleep(delayMs);
            }
            User32.PostMessage(wnd, User32.WM_KEYUP, (IntPtr)vkCode, (UIntPtr)lParam.getint());
            if (IsShift(comboState))
            {
                ReleaseShift(wnd);
            }
        }
Exemplo n.º 2
0
        public static void sendKeystroke()
        {
            const uint WM_KEYDOWN    = 0x0100;
            const uint WM_KEYUP      = 0x0101;
            const uint WM_SYSKEYDOWN = 0x0104;
            const uint Key_Down      = 0x0001;
            const uint Key_Up        = 0x0002;

            const uint VK_F1 = 0x70;
            const int  VK_1  = 0x30;

            IntPtr hWnd = FindWindow(null, "Idle Champions");

            extraKeyInfo lParam = new extraKeyInfo();

            lParam.scanCode    = (char)MapVirtualKey(VK_F1, 0);
            lParam.repeatCount = 1;
            int myParam = lParam.getint();
            var test    = SendMessage(hWnd, WM_KEYDOWN, (IntPtr)VK_F1, (IntPtr)myParam);

            lParam.repeatCount     = 1;
            lParam.prevKeyState    = 1;
            lParam.transitionState = 1;
            System.Threading.Thread.Sleep(100);
            myParam = lParam.getint();
            var test2 = SendMessage(hWnd, WM_KEYUP, (IntPtr)VK_F1, (IntPtr)myParam);
        }
Exemplo n.º 3
0
        public static void SendChar(IntPtr wnd, Char ch)
        {
            ushort       temp       = (ushort)User32.VkKeyScan(ch);
            byte         vkCode     = (byte)(0xFF & temp);
            byte         comboState = (byte)(temp >> 8);
            extraKeyInfo lParam     = new extraKeyInfo();

            lParam.scanCode    = (char)User32.MapVirtualKey(vkCode, User32.MAPVK_VK_TO_VSC);
            lParam.repeatCount = 1;
            User32.PostMessage(wnd, User32.WM_CHAR, (IntPtr)ch, (UIntPtr)lParam.getint());
        }
Exemplo n.º 4
0
        public static void SendK(IntPtr wnd, Char ch, Int32 del)
        {
            uint         vkCode = (byte)(VkKeyScan(ch));
            extraKeyInfo lParam = new extraKeyInfo();

            lParam.scanCode = (char)MapVirtualKey((int)vkCode, MAPVK_VK_TO_VSC);
            PostMessage(wnd, WM_KEYDOWN, 'ы', lParam.getint()); //'ы'
            lParam.repeatCount     = 1;
            lParam.prevKeyState    = 1;
            lParam.transitionState = 1;
            System.Threading.Thread.Sleep(del);
            //PostMessage(wnd, WM_CHAR, (IntPtr)251, new IntPtr(0));
            PostMessage(wnd, WM_KEYUP, 'ы', lParam.getint());
        }