Haunted Desktop Prank

Picture
For this tutorial you will need the following:

  • PictureBox
  • Timer Control
Dock the picturebox into the form and set the size mode to "stretch".  Now choose an animated GIF file or anypicture image with a solid colour background.  Now set the following properties on your form:




 

  • BackColor  (same color as your image background)
  • FormBorderStyle = None
  • ShowInTaskbar = False
  • StartPosition = CenterScreen
  • TopMost = True
  • TransparencyKey (same color as your image background)
  • Enable the Timer control
 

Then copy and paste this code into your form and thats all you need to do:

Public Class Form1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

'This is what happens when the timer runs out
Me.Visible = True
Timer1.Enabled = False
'This is how long the timer runs - set at 8 seconds
Timer1.Interval = 8000
End Sub

Private Sub PictureBox1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick

'When you click the ghost the form goes away and the timer restarts
Dim generator As New Random
Dim randomValue AsInteger
Me.Visible = False

'This is X & Y of screen location
randomValue = generator.Next(10, 800)
Me.SetDesktopLocation(randomValue, randomValue)
Timer1.Enabled =
True
End Sub
End
Class