Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Runtime.InteropServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12.  
  13. namespace WindowsFormsApplication1
  14. {
  15. public partial class FormOverlay : Form
  16. {
  17.  
  18.  
  19.  
  20. public struct RECT
  21. {
  22. public int left, top, right, bottom;
  23. }
  24.  
  25. RECT rect;
  26.  
  27. Graphics g;
  28.  
  29.  
  30.  
  31.  
  32.  
  33. Pen myPen = new Pen(Color.Red);
  34.  
  35. public const string WINDOW_NAME = "Battlefield 3™";
  36. IntPtr handle = FindWindow(null, WINDOW_NAME);
  37.  
  38. [DllImport("user32.dll")]
  39. static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
  40.  
  41. [DllImport("user32.dll", SetLastError = true)]
  42. static extern int GetWindowLong(IntPtr hWnd, int nIndex);
  43.  
  44. [DllImport("user32.dll", SetLastError = true)]
  45. static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
  46.  
  47. [DllImport("user32.dll")]
  48. [return: MarshalAs(UnmanagedType.Bool)]
  49. public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
  50.  
  51. public FormOverlay()
  52. {
  53. InitializeComponent();
  54. }
  55.  
  56. private void FormOverlay_Load(object sender, EventArgs e)
  57. {
  58.  
  59. this.BackColor = Color.Wheat;
  60. this.TransparencyKey = Color.Wheat;
  61. this.TopMost = true;
  62. this.FormBorderStyle = FormBorderStyle.None;
  63.  
  64. int initialStyle = GetWindowLong(this.Handle, -20);
  65. SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
  66.  
  67. GetWindowRect(handle, out rect);
  68. this.Size = new Size(rect.right - rect.left, rect.bottom - rect.top);
  69. this.Top = rect.top;
  70. this.Left = rect.left;
  71. }
  72.  
  73.  
  74. private void FormOverlay_Paint(object sender, PaintEventArgs e)
  75. {
  76. g = e.Graphics;
  77. g.DrawRectangle(myPen, 100, 100, 200, 200);
  78. g.DrawString("All your base are belong to us", this.Font, Brushes.Red, new PointF(500f, 500f));
  79.  
  80. }
  81.  
  82.  
  83.  
  84. private void update_Tick(object sender, EventArgs e)
  85. {
  86. FormOverlay_Load(null, null);
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement