Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.30 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Runtime.InteropServices;
  4. using System.Windows.Forms;
  5.  
  6. namespace BlindSpot
  7. {
  8.     public partial class Form1 : Form
  9.     {
  10.         public Form1()
  11.         {
  12.             InitializeComponent();
  13.         }
  14.  
  15.         Point p1 = new Point(2792, 850);
  16.         Point p2 = new Point(3000, 1024);
  17.         Rectangle rect;
  18.        
  19.         private void Form1_Paint(object sender, PaintEventArgs e)
  20.         {
  21.             e.Graphics.CopyFromScreen(p1, Point.Empty, rect.Size);
  22.             CURSORINFO pci;
  23.             pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
  24.  
  25.             if (GetCursorInfo(out pci))
  26.             {
  27.                 if (pci.flags == CURSOR_SHOWING)
  28.                 {
  29.                     DrawIcon(e.Graphics.GetHdc(), pci.ptScreenPos.x - p1.X, pci.ptScreenPos.y - p1.Y, pci.hCursor);
  30.                     e.Graphics.ReleaseHdc();
  31.                 }
  32.             }
  33.         }
  34.  
  35.         protected override void OnPaintBackground(PaintEventArgs e)
  36.         {
  37.         }
  38.  
  39.         private void timer1_Tick(object sender, EventArgs e)
  40.         {
  41.             if (rect.Contains(Cursor.Position))
  42.             {
  43.                 if (!Visible) Show();
  44.                 Invalidate();
  45.             }
  46.             else if (Visible)
  47.             {
  48.                 Hide();
  49.             }
  50.         }
  51.  
  52.         private void Form1_Load(object sender, EventArgs e)
  53.         {
  54.             rect = new Rectangle(p1, new Size(p2.X - p1.X, p2.Y - p1.Y));
  55.             ClientSize = rect.Size;
  56.             timer1.Interval = 33;
  57.             timer1.Enabled = true;
  58.         }
  59.  
  60.  
  61.  
  62.         #region Native stuff
  63.         [StructLayout(LayoutKind.Sequential)]
  64.         struct CURSORINFO
  65.         {
  66.             public Int32 cbSize;
  67.             public Int32 flags;
  68.             public IntPtr hCursor;
  69.             public POINTAPI ptScreenPos;
  70.         }
  71.  
  72.         [StructLayout(LayoutKind.Sequential)]
  73.         struct POINTAPI
  74.         {
  75.             public int x;
  76.             public int y;
  77.         }
  78.  
  79.         [DllImport("user32.dll")]
  80.         static extern bool GetCursorInfo(out CURSORINFO pci);
  81.  
  82.         [DllImport("user32.dll")]
  83.         static extern bool DrawIcon(IntPtr hDC, int X, int Y, IntPtr hIcon);
  84.  
  85.         const Int32 CURSOR_SHOWING = 0x00000001;
  86.         #endregion
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement