Пример #1
0
        public static void GetSmartInfo(ref int wHdl, ref StringBuilder clsName, ref StringBuilder wndText)
        {
            POINTAPI Pnt = new POINTAPI();

            GetCursorPos(ref Pnt);
            wHdl = WindowFromPoint(Pnt.x, Pnt.y);
            GetClassName(wHdl, clsName, 128);
            GetWindowText(wHdl, wndText, 128);
        }
Пример #2
0
        public static void GetWindowFromPoint(ref int hwnd, ref StringBuilder winText, ref StringBuilder clsName, ref StringBuilder pText)
        {
            int parentHandle = 0;
            //int maxLen = 10000; //need to modify text chapter 4

            POINTAPI pnt = new POINTAPI();

            parentHandle = GetCursorPos(ref pnt);
            hwnd         = WindowFromPoint(pnt.x, pnt.y);

            winText      = new StringBuilder(maxLen);
            parentHandle = GetWindowText(hwnd, winText, maxLen);

            clsName      = new StringBuilder(maxLen);
            parentHandle = GetClassName(hwnd, clsName, maxLen);

            pText        = new StringBuilder(maxLen);
            parentHandle = GetParent(hwnd);
            parentHandle = GetWindowText(parentHandle, pText, maxLen);
        }
Пример #3
0
        public static void MoveMouseInsideHwnd(int hwnd, int xPos, int yPos, RectPosition rctPos)
        {
            int xPixel = xPos;            //10;
            int yPixel = yPos;            //10;

            if (!rctPos.Equals(RectPosition.AnySpot))
            {
                xPixel = 4;
                yPixel = 4;
            }

            CenterMouseOn(hwnd);

            int      width  = 0;
            int      height = 0;
            POINTAPI pa     = new POINTAPI();

            GetWindowSize(hwnd, ref width, ref height);
            GetCursorPos(ref pa);

            switch (rctPos)
            {
            case RectPosition.LeftTop:
                xPixel = (pa.x - width / 2) + xPixel % width;
                yPixel = (pa.y - height / 2) + yPixel % height;
                break;

            case RectPosition.LeftBottom:
                xPixel = (pa.x - width / 2) + xPixel % width;
                yPixel = (pa.y + height / 2) - yPixel % height;
                break;

            case RectPosition.RightTop:
                xPixel = (pa.x + width / 2) - xPixel % width;
                yPixel = (pa.y - height / 2) + yPixel % height;
                break;

            case RectPosition.RightBottom:
                xPixel = (pa.x + width / 2) - xPixel % width;
                yPixel = (pa.y + height / 2) - yPixel % height;
                break;

            case RectPosition.MiddleTop:
                xPixel = (pa.x);
                yPixel = (pa.y - height / 2) + yPixel % height;
                break;

            case RectPosition.MiddleBottom:
                xPixel = (pa.x);
                yPixel = (pa.y + height / 2) - yPixel % height;
                break;

            case RectPosition.AnySpot:
                xPixel = (pa.x - width / 2) + xPixel % width;
                yPixel = (pa.y - height / 2) + yPixel % height;
                break;
            }

            //if (rC>0)
            //{
            MoveMouse(hwnd, xPixel, yPixel);
            //}
        }
Пример #4
0
 public static extern int GetCursorPos([MarshalAs(UnmanagedType.Struct)] ref POINTAPI lpPoint);