Haunted Desktop Prank
For this tutorial you will need the following:
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
- PictureBox
- Timer Control
- 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