Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class FormOverlay : Form
- {
- public struct RECT
- {
- public int left, top, right, bottom;
- }
- RECT rect;
- Graphics g;
- Pen myPen = new Pen(Color.Red);
- public const string WINDOW_NAME = "Battlefield 3™";
- IntPtr handle = FindWindow(null, WINDOW_NAME);
- [DllImport("user32.dll")]
- static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
- [DllImport("user32.dll", SetLastError = true)]
- static extern int GetWindowLong(IntPtr hWnd, int nIndex);
- [DllImport("user32.dll", SetLastError = true)]
- static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
- public FormOverlay()
- {
- InitializeComponent();
- }
- private void FormOverlay_Load(object sender, EventArgs e)
- {
- this.BackColor = Color.Wheat;
- this.TransparencyKey = Color.Wheat;
- this.TopMost = true;
- this.FormBorderStyle = FormBorderStyle.None;
- int initialStyle = GetWindowLong(this.Handle, -20);
- SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
- GetWindowRect(handle, out rect);
- this.Size = new Size(rect.right - rect.left, rect.bottom - rect.top);
- this.Top = rect.top;
- this.Left = rect.left;
- }
- private void FormOverlay_Paint(object sender, PaintEventArgs e)
- {
- g = e.Graphics;
- g.DrawRectangle(myPen, 100, 100, 200, 200);
- g.DrawString("All your base are belong to us", this.Font, Brushes.Red, new PointF(500f, 500f));
- }
- private void update_Tick(object sender, EventArgs e)
- {
- FormOverlay_Load(null, null);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement