public void Follower()
        {
            //EnumWindowsItem child = WC.GetChildWindow("Map", "");

            //if (child == null)
            //{
            //    return;
            //}

            while (WC.Hwnd2ID(ParentHwnd) != 0) // old way didn't work, since the handle wasn't to the child window
            {
                try
                {
                    int px = WC.winGetPosition(ParentHwnd).X;
                    int py = WC.winGetPosition(ParentHwnd).Y;
                    int pw = WC.winGetSize(ParentHwnd).Width;
                    int ph = WC.winGetSize(ParentHwnd).Height;

                    int x = WC.winGetPosition(ExternalHwnd).X;
                    int y = WC.winGetPosition(ExternalHwnd).Y;
                    int w = WC.winGetSize(ExternalHwnd).Width;
                    int h = WC.winGetSize(ExternalHwnd).Height;

                    if (followsParent)
                    {
                        switch (winHanLocation) // hopefully works not tested
                        {
                        case WindowHandlingLocation.TopLeft2mid:
                            WC.winSetPosition(ExternalHwnd, px + offsetX, py + offsetY);
                            break;

                        case WindowHandlingLocation.TopRight2mid:
                            WC.winSetPosition(ExternalHwnd, px + pw - w - offsetX, py + offsetY);
                            break;

                        case WindowHandlingLocation.BottomLeft2mid:
                            WC.winSetPosition(ExternalHwnd, px + offsetX, py + ph - h - offsetY);
                            break;

                        case WindowHandlingLocation.BottomRight2mid:
                            WC.winSetPosition(ExternalHwnd, px + pw - w - offsetX, py + ph - h - offsetY);
                            break;
                        }
                    }
                    else
                    {
                        switch (winHanLocation)
                        {
                        case WindowHandlingLocation.TopLeft2mid:

                            WC.winSetPosition(ParentHwnd, x + offsetX, y + offsetY);
                            break;

                        case WindowHandlingLocation.TopRight2mid:
                            WC.winSetPosition(ParentHwnd, x + w - pw - offsetX, y + offsetY);
                            break;

                        case WindowHandlingLocation.BottomLeft2mid:
                            WC.winSetPosition(ParentHwnd, x + offsetX, y + h - ph - offsetY);
                            break;

                        case WindowHandlingLocation.BottomRight2mid:
                            WC.winSetPosition(ParentHwnd, x + w - pw - offsetX, y + h - ph - offsetY);
                            break;
                        }
                    }
                }
                catch { Toggle(false); }
                Thread.Sleep(333);
            }
        }
 public ReadWriteMemory(IntPtr hwnd)
 {
     this.m_lpHandle = Imports.OpenProcess((Imports.ProcessAccessFlags) 0x1f0fff, false, WC.Hwnd2ID(hwnd));
     if (this.m_lpHandle.ToInt32() == 0)
     {
         Console.WriteLine(string.Concat(new object[] { "Failed To Open Process: ", hwnd, ". Error: ", Imports.GetLastError() }), "Error");
     }
 }
Exemple #3
0
        public void Follower()
        {
            EnumWindowsItem childWindow = WC.GetChildWindow("Map", "");

            if (childWindow != null)
            {
                goto Label_0253;
            }
            return;

Label_0249:
            Thread.Sleep(0x14d);
Label_0253:
            if (WC.Hwnd2ID(childWindow.Handle) != 0)
            {
                try
                {
                    int x      = WC.winGetPosition(this.ParentHwnd).X;
                    int y      = WC.winGetPosition(this.ParentHwnd).Y;
                    int width  = WC.winGetSize(this.ParentHwnd).Width;
                    int height = WC.winGetSize(this.ParentHwnd).Height;
                    int num5   = WC.winGetPosition(this.ExternalHwnd).X;
                    int num6   = WC.winGetPosition(this.ExternalHwnd).Y;
                    int num7   = WC.winGetSize(this.ExternalHwnd).Width;
                    int num8   = WC.winGetSize(this.ExternalHwnd).Height;
                    if (this.followsParent)
                    {
                        switch (this.winHanLocation)
                        {
                        case WindowHandlingLocation.TopLeft2mid:
                            WC.winSetPosition(this.ExternalHwnd, x + this.offsetX, y + this.offsetY);
                            goto Label_0249;

                        case WindowHandlingLocation.TopRight2mid:
                            WC.winSetPosition(this.ExternalHwnd, ((x + width) - num7) - this.offsetX, y + this.offsetY);
                            goto Label_0249;

                        case WindowHandlingLocation.BottomLeft2mid:
                            WC.winSetPosition(this.ExternalHwnd, x + this.offsetX, ((y + height) - num8) - this.offsetY);
                            goto Label_0249;

                        case WindowHandlingLocation.BottomRight2mid:
                            WC.winSetPosition(this.ExternalHwnd, ((x + width) - num7) - this.offsetX, ((y + height) - num8) - this.offsetY);
                            goto Label_0249;
                        }
                    }
                    else
                    {
                        switch (this.winHanLocation)
                        {
                        case WindowHandlingLocation.TopLeft2mid:
                            WC.winSetPosition(this.ParentHwnd, num5 + this.offsetX, num6 + this.offsetY);
                            goto Label_0249;

                        case WindowHandlingLocation.TopRight2mid:
                            WC.winSetPosition(this.ParentHwnd, ((num5 + num7) - width) - this.offsetX, num6 + this.offsetY);
                            goto Label_0249;

                        case WindowHandlingLocation.BottomLeft2mid:
                            WC.winSetPosition(this.ParentHwnd, num5 + this.offsetX, ((num6 + num8) - height) - this.offsetY);
                            goto Label_0249;

                        case WindowHandlingLocation.BottomRight2mid:
                            WC.winSetPosition(this.ParentHwnd, ((num5 + num7) - width) - this.offsetX, ((num6 + num8) - height) - this.offsetY);
                            goto Label_0249;
                        }
                    }
                }
                catch
                {
                    this.Toggle(false);
                }
                goto Label_0249;
            }
        }