This is one of the easiest methods to overlay the screen and the fastest. I don't know if you can use it in games, I haven't tried it (I don't have any games ).
●First start of by creating some variables
Code:
Private PenColor As Pen = Pens.Blue 'The pen to use when drawing the crosshair.
Private Diameter As Integer = 250 'The diameter of the outer circle.
Private DrawMidPoint As Boolean = False 'Weather or not to draw the mid point for better accuracy.
Private ScreenSize As Size = Screen.PrimaryScreen.Bounds.Size
●Now we change some of the form properties. You'll need to change the size of the form dynamically however (to the bounds of the screen) if you want it to work for everyone.
Code:
With Me
.StartPosition = FormStartPosition.Manual
.Location = New Point(0, 0)
.FormBorderStyle = BorderStyle.None
.Size = New Size(ScreenSize.Width, ScreenSize.Height)
.WindowState = FormWindowState.Maximized
.Text = "External Crosshair"
.TopMost = True
.BackColor = Color.White
.TransparencyKey = .BackColor
.Icon = SystemIcons.Application
End With
●And now to actually draw the crosshair using the 'paint' form event. I'm not really sure about the measurements which I have done, the crosshair may not be exactly it in the center. So you can make some minor adjust
Code:
Private Sub OverlayPaint(ByVal sender As System.Object, ByVal e As PaintEventArgs) Handles Me.Paint
e.Graphics.DrawArc(PenColor, New Rectangle(New Point((e.ClipRectangle.Size.Width / 2) - (Diameter / 2), (e.ClipRectangle.Size.Height / 2) - (Diameter / 2)), New Size(Diameters, Diameter)), 0, 360)
If DrawMidPoint = True Then
e.Graphics.DrawArc(PenColor, New Rectangle(New Point((e.ClipRectangle.Size.Width / 2) - (10 / 2), (e.ClipRectangle.Size.Height / 2) - (10 / 2)), New Size(10, 10)), 0, 360)
End If
e.Graphics.Dispose()
End Sub
●You can change the variables at any time, but remember to redraw the graphics once you have done so using the 'refresh' function.
You may be wondering why couldn't we just get a handle to the screen and directly draw on it?, but I've already tried it and it will NOT work out. The windows screen rendering overides your graphics once the controls has changed. So you'll have to keep drawing it over and over which is really laggy.