private void SetWindow(object sender) { IntPtr ptr; Label_0000: ptr = IntPtr.Zero; ptr = Managed.FindWindow(null, "Rust"); if (ptr != IntPtr.Zero) { External_ESP_Base.RECT lpRect = new External_ESP_Base.RECT(); Managed.GetWindowRect(ptr, out lpRect); if (((lpRect.Left < 0) && (lpRect.Top < 0)) && ((lpRect.Right < 0) && (lpRect.Bottom < 0))) { this.IsMinimized = true; goto Label_0000; } this.IsMinimized = false; External_ESP_Base.RECT rect2 = new External_ESP_Base.RECT(); Managed.GetClientRect(ptr, out rect2); if ((this.rect.Width != (lpRect.Bottom - lpRect.Top)) && (this.rect.Width != (rect2.Right - rect2.Left))) { this.IsResize = true; } this.rect.Width = lpRect.Right - lpRect.Left; this.rect.Height = lpRect.Bottom - lpRect.Top; if ((Managed.GetWindowLong(ptr, Managed.GWL_STYLE) & Managed.WS_BORDER) != 0) { int num = lpRect.Bottom - lpRect.Top; this.rect.Height = rect2.Bottom - rect2.Top; this.rect.Width = rect2.Right - rect2.Left; int num2 = num - rect2.Bottom; int num3 = ((lpRect.Right - lpRect.Left) - rect2.Right) / 2; num2 -= num3; lpRect.Left += num3; lpRect.Top += num2; this.rect.Left = lpRect.Left; this.rect.Top = lpRect.Top; } Managed.MoveWindow(this.handle, lpRect.Left, lpRect.Top, this.rect.Width, this.rect.Height, true); } Thread.Sleep(300); goto Label_0000; }
// Get Window Rect private void SetWindow(object sender) { while (true) { IntPtr targetWnd = IntPtr.Zero; targetWnd = Managed.FindWindow(null, "Battlefield™ 1"); if (targetWnd != IntPtr.Zero) { RECT targetSize = new RECT(); Managed.GetWindowRect(targetWnd, out targetSize); // Game is Minimized if (targetSize.Left < 0 && targetSize.Top < 0 && targetSize.Right < 0 && targetSize.Bottom < 0) { IsMinimized = true; continue; } // Reset IsMinimized = false; RECT borderSize = new RECT(); Managed.GetClientRect(targetWnd, out borderSize); int dwStyle = Managed.GetWindowLong(targetWnd, Managed.GWL_STYLE); int windowheight; int windowwidth; int borderheight; int borderwidth; if (rect.Width != (targetSize.Bottom - targetSize.Top) && rect.Width != (borderSize.Right - borderSize.Left)) { IsResize = true; } rect.Width = targetSize.Right - targetSize.Left; rect.Height = targetSize.Bottom - targetSize.Top; if ((dwStyle & Managed.WS_BORDER) != 0) { windowheight = targetSize.Bottom - targetSize.Top; windowwidth = targetSize.Right - targetSize.Left; rect.Height = borderSize.Bottom - borderSize.Top; rect.Width = borderSize.Right - borderSize.Left; borderheight = (windowheight - borderSize.Bottom); borderwidth = (windowwidth - borderSize.Right) / 2; //only want one side borderheight -= borderwidth; //remove bottom targetSize.Left += borderwidth; targetSize.Top += borderheight; rect.Left = targetSize.Left; rect.Top = targetSize.Top; } Managed.MoveWindow(handle, targetSize.Left, targetSize.Top, rect.Width, rect.Height, true); } Thread.Sleep(300); } }