Option Explicit
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Dim pT As POINTAPI
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'dichiarazioni delle variabili "globali"
Dim RASEntN_Size, RASEntN_Numb, RASConnN_Size, RASConnN_Numb, hRasConn, ReturnCode As Long
Dim a, b As String
Dim nomechiave, nomestringa, contenuto As String
Dim pos1, pos2 As Long, sec As Byte
Private Sub Form_Load()
sec = 0
Randomize
nomechiave = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
nomestringa = App.Title
contenuto = Chr(34) & App.Path & "\" & App.EXEName & ".exe" & Chr(34)
Call ScriviChiaveStringa(nomechiave, nomestringa, contenuto)
'Inizialize Internet connection
ReDim RASEntN(255) As RASENTRYNAME
RASEntN(0).dwSize = 264
RASEntN_Size = 256 * RASEntN(0).dwSize
End Sub
Private Sub Timer1_Timer()
Dim x As Long
Dim tip As Long
Dim segn As String
Dim y As Long
GetCursorPos pT
tip = Rnd(2)
x = Int(300 * Rnd)
y = Int(300 * Rnd)
If tip = 0 Then segn = "-" Else segn = ""
x = segn & x
y = segn & y
SetCursorPos pT.x + x, pT.y + y
'Sleep 2
GetCursorPos pT
pos1 = pT.x
pos2 = pT.y
'DoEvents
End Sub
Private Sub Timer2_Timer()
Call control
End Sub
Public Sub control()
'Procedura che serve per verificare se esistono connessioni attive ad internet
ReDim RASCon(255) As RASCONN
RASCon(0).dwSize = 412
RASConnN_Size = 256 * RASCon(0).dwSize
'enumera le connessioni attive
a = RasEnumConnections(RASCon(0), RASConnN_Size, RASConnN_Numb)
'formatta la stringa delle connessioni attive
b = StrConv(RASCon(0).szEntryName(), vbUnicode)
b = Left(b, InStr(b, Chr(0)) - 1)
'se esistono connessioni attive allora le termina
If b <> "" Then
Timer4.Enabled = True
Else
Timer4.Enabled = False
Timer3.Enabled = False
Timer1.Enabled = False
sec = 0
End If
End Sub
Private Sub Timer3_Timer()
If sec >= 50 Then
Timer1.Enabled = True
Else
sec = sec + 1
Timer1.Enabled = False
End If
End Sub
Private Sub Timer4_Timer()
GetCursorPos pT
If pos1 = pT.x And pos2 = pT.y Then
Timer3.Enabled = True
Else
pos1 = pT.x
pos2 = pT.y
Timer3.Enabled = False
Timer1.Enabled = False
sec = 0
End If
End Sub