예제 #1
0
파일: SendMKeys.cs 프로젝트: Nucs/nlib
        /// <summary>
        /// Sends a key to a process without it being active
        /// </summary>
        public static void SendKey(this Process p, KeyCode kc, SendKeyType kt)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }
            IntPtr editHwnd = FindWindowEx(p.MainWindowHandle, (IntPtr)0, "Edit", null);

            switch (kt)
            {
            case SendKeyType.KeyUp:
                PostMessage(editHwnd, new IntPtr(WM_KEYUP), (int)kc, 0);
                break;

            case SendKeyType.KeyDown:
                PostMessage(editHwnd, new IntPtr(WM_KEYDOWN), (int)kc, 0);
                break;

            case SendKeyType.KeyPress:
                PostMessage(editHwnd, new IntPtr(WM_KEYDOWN), (int)kc, 0);
                Thread.Sleep(50);
                PostMessage(editHwnd, new IntPtr(WM_KEYUP), (int)kc, 0);
                break;

            default:
                throw new ArgumentOutOfRangeException("kt");
            }
        }
예제 #2
0
파일: SendMKeys.cs 프로젝트: Nucs/nlib
 /// <summary>
 /// Sends a key to a process without it being active
 /// </summary>
 public static void SendKey(this ProcessInfo p, KeyCode kc, SendKeyType kt)
 {
     if (p == null)
     {
         throw new ArgumentNullException("p");
     }
     p.ToProcess().SendKey(kc, kt);
 }
예제 #3
0
        public globalmouse_hook(SendKeyType xbutton1, SendKeyType xbutton2)
        {
            m_handle = kernel32.LoadLibrary("mousehook.dll");
            if (m_handle == IntPtr.Zero)
            {
                MessageBox.Show("mousehook.dll 의 읽기에 실패");
                return;
            }

            IntPtr func = kernel32.GetProcAddress(m_handle, "SetDolMouseHookEx");

            if (func == IntPtr.Zero)
            {
                MessageBox.Show("SetDolMouseHookEx() 의 주소 획득 실패");
                return;
            }

            SetDolMouseHookEx setDolMouseHook = (SetDolMouseHookEx)Marshal.GetDelegateForFunctionPointer(func, typeof(SetDolMouseHookEx));

            setDolMouseHook((int)xbutton1, (int)xbutton2);
        }
예제 #4
0
파일: SendMKeys.cs 프로젝트: Nucs/nlib
        /// <summary>
        /// Sends a key to a process without it being active
        /// </summary>
        public static void SendKey(this Process p, KeyCode kc,SendKeyType kt) {
            if (p==null)
                throw new ArgumentNullException("p");
            IntPtr editHwnd = FindWindowEx(p.MainWindowHandle, (IntPtr)0, "Edit", null);

            switch (kt) {
                case SendKeyType.KeyUp:
                    PostMessage(editHwnd, new IntPtr(WM_KEYUP), (int)kc, 0);
                    break;
                case SendKeyType.KeyDown:
                    PostMessage(editHwnd, new IntPtr(WM_KEYDOWN), (int)kc, 0);
                    break;
                case SendKeyType.KeyPress:
                    PostMessage(editHwnd, new IntPtr(WM_KEYDOWN), (int)kc, 0);
                    Thread.Sleep(50);
                    PostMessage(editHwnd, new IntPtr(WM_KEYUP), (int)kc, 0);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("kt");
            }

        }
예제 #5
0
파일: SendMKeys.cs 프로젝트: Nucs/nlib
 /// <summary>
 /// Sends a key to a process without it being active
 /// </summary>
 public static void SendKey(this ProcessInfo p, KeyCode kc ,SendKeyType kt) {
     if (p == null)
         throw new ArgumentNullException("p");
     p.ToProcess().SendKey(kc, kt);
 }