Beispiel #1
0
 private void KeyBoardDown(IntPtr intPtr, int key)
 {
     Thread.Sleep(1000);
     WinApi.PostMessage(intPtr, 0x100, key, 0);
     Thread.Sleep(1000);
     WinApi.PostMessage(intPtr, 0x100, key, 0);
     Thread.Sleep(1000);
     WinApi.PostMessage(intPtr, 0x100, key, 0);
     Thread.Sleep(1000);
 }
Beispiel #2
0
        /// <summary>
        /// 鼠标点击某窗体,相对位置
        /// </summary>
        public static bool ClickLocation(IntPtr hWnd, int x, int y)
        {
            Point point        = new Point(x, y);
            var   btDownResult = WinApi.PostMessage(hWnd, WmLbuttondown, 0, MAKEPARAM(point.X, point.Y));

            Thread.Sleep(50);
            var btUpResult = WinApi.PostMessage(hWnd, WmLbuttonup, 0, MAKEPARAM(point.X, point.Y));

            return(btDownResult && btUpResult);
        }