예제 #1
0
파일: Utils.cs 프로젝트: pointydev/SAM
        public static void SendSpace(IntPtr hwnd, VirtualInputMethod inputMethod)
        {
            switch (inputMethod)
            {
            case VirtualInputMethod.SendMessage:
                SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, IntPtr.Zero);
                SendMessage(hwnd, WM_KEYUP, VK_SPACE, IntPtr.Zero);
                break;

            case VirtualInputMethod.PostMessage:
                PostMessage(hwnd, WM_KEYDOWN, (IntPtr)VK_SPACE, IntPtr.Zero);
                PostMessage(hwnd, WM_KEYUP, (IntPtr)VK_SPACE, IntPtr.Zero);
                break;

            case VirtualInputMethod.SendWait:
                System.Windows.Forms.SendKeys.SendWait(" ");
                break;
            }
        }
예제 #2
0
파일: Utils.cs 프로젝트: pointydev/SAM
        public static void SendCharacter(IntPtr hwnd, VirtualInputMethod inputMethod, char c)
        {
            switch (inputMethod)
            {
            case VirtualInputMethod.SendMessage:
                SendMessage(hwnd, WM_CHAR, c, IntPtr.Zero);
                break;

            case VirtualInputMethod.PostMessage:
                PostMessage(hwnd, WM_CHAR, (IntPtr)c, IntPtr.Zero);
                break;

            default:
                if (Utils.IsSpecialCharacter(c))
                {
                    if (inputMethod == VirtualInputMethod.SendWait)
                    {
                        System.Windows.Forms.SendKeys.SendWait("{" + c.ToString() + "}");
                    }
                    else
                    {
                        System.Windows.Forms.SendKeys.Send("{" + c.ToString() + "}");
                    }
                }
                else
                {
                    if (inputMethod == VirtualInputMethod.SendWait)
                    {
                        System.Windows.Forms.SendKeys.SendWait(c.ToString());
                    }
                    else
                    {
                        System.Windows.Forms.SendKeys.Send(c.ToString());
                    }
                }
                break;
            }
        }