Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- namespace BlindSpot
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- Point p1 = new Point(2792, 850);
- Point p2 = new Point(3000, 1024);
- Rectangle rect;
- private void Form1_Paint(object sender, PaintEventArgs e)
- {
- e.Graphics.CopyFromScreen(p1, Point.Empty, rect.Size);
- CURSORINFO pci;
- pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
- if (GetCursorInfo(out pci))
- {
- if (pci.flags == CURSOR_SHOWING)
- {
- DrawIcon(e.Graphics.GetHdc(), pci.ptScreenPos.x - p1.X, pci.ptScreenPos.y - p1.Y, pci.hCursor);
- e.Graphics.ReleaseHdc();
- }
- }
- }
- protected override void OnPaintBackground(PaintEventArgs e)
- {
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (rect.Contains(Cursor.Position))
- {
- if (!Visible) Show();
- Invalidate();
- }
- else if (Visible)
- {
- Hide();
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- rect = new Rectangle(p1, new Size(p2.X - p1.X, p2.Y - p1.Y));
- ClientSize = rect.Size;
- timer1.Interval = 33;
- timer1.Enabled = true;
- }
- #region Native stuff
- [StructLayout(LayoutKind.Sequential)]
- struct CURSORINFO
- {
- public Int32 cbSize;
- public Int32 flags;
- public IntPtr hCursor;
- public POINTAPI ptScreenPos;
- }
- [StructLayout(LayoutKind.Sequential)]
- struct POINTAPI
- {
- public int x;
- public int y;
- }
- [DllImport("user32.dll")]
- static extern bool GetCursorInfo(out CURSORINFO pci);
- [DllImport("user32.dll")]
- static extern bool DrawIcon(IntPtr hDC, int X, int Y, IntPtr hIcon);
- const Int32 CURSOR_SHOWING = 0x00000001;
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement