Anda di halaman 1dari 1

Public Class Form1

<System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="GetWindowLo
ng")> Public Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As
Integer) As Integer
End Function
<System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="SetWindowLo
ng")> Public Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As
Integer, ByVal dwNewLong As Integer) As Integer
End Function
Const xOff As Integer = 0 'How far the form will be away from the curson in x-di
rection
Const yOff As Integer = 0 'How far the form will be away from the curson in y-di
rection
Private WithEvents Timer1 As Timer
Private Sub Timer1_Tick(sender As Object, e As EventArgs)
Me.SetDesktopLocation(MousePosition.X - xOff, MousePosition.Y - yOff) 'Set t
he form's position
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Setup a timer
Timer1 = New Timer
Timer1.Interval = 1
AddHandler Timer1.Tick, AddressOf Timer1_Tick
Timer1.Start()
'Set the form to clickthrough
'See http://stackoverflow.com/questions/18294658/vb-net-click-through-form
Dim InitialStyle As Integer
InitialStyle = GetWindowLong(Me.Handle, -20)
SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000 Or &H20) 'Makes the wi
ndow "click-throughable"
End Sub
End Class