codice:
Imports System.Threading
Public Class Form1
Enum meFlags As Integer
MOUSEEVENTF_MOVE = &H1
MOUSEEVENTF_LEFTDOWN = &H2
MOUSEEVENTF_LEFTUP = &H4
MOUSEEVENTF_RIGHTDOWN = &H8
MOUSEEVENTF_RIGHTUP = &H10
MOUSEEVENTF_MIDDLEDOWN = &H20
MOUSEEVENTF_MIDDLEUP = &H40
MOUSEEVENTF_XDOWN = &H80
MOUSEEVENTF_XUP = &H100
MOUSEEVENTF_WHEEL = &H800
MOUSEEVENTF_VIRTUALDESK = &H4000
MOUSEEVENTF_ABSOLUTE = &H8000
End Enum
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As meFlags, ByVal Coords As Drawing.Point, ByVal dwData As Integer, ByVal dwExtraInfo As UIntPtr)
Private Declare Auto Function SetCursorPos Lib "user32.dll" (ByVal x As Integer, ByVal y As Integer) As Integer
'Dim LocalMousePosition As Point
Private Declare Function GetPixel Lib "gdi32.dll" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer) As Integer
Private Declare Function GetWindowDC Lib "user32.dll" (ByVal hwnd As Integer) As Integer
Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Const tt = 300
Dim hwnd As Double
Dim cc As Double
Dim ax1, ay1, az, jk, hk As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.TopMost = True
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Process.Start("http://mail.tiscali.it/")
Timer1.Enabled = True
End Sub
Private Sub Dati1()
ax1 = 1050 'posizione X del textbox del nome utente
ay1 = 370 'posizione Y del textbox del nome utente
SetCursorPos(ax1, ay1)
Singolo() 'simula click del mouse
Clipboard.Clear()
Clipboard.SetText("utente")
Application.DoEvents()
SendKeys.Send("+{INS}") 'Shift + INS (incolla)
End Sub
Private Sub Dati3()
ax1 = 1050 'posizione X del textbox della password
ay1 = 445 'posizione Y del textbox della password
SetCursorPos(ax1, ay1)
Singolo()
Clipboard.Clear()
Clipboard.SetText("password")
Application.DoEvents()
SendKeys.Send("+{INS}") 'Shift + INS (incolla)
End Sub
Private Sub Singolo()
'Click singolo
Dim tpnt As New Drawing.Point(0, 0)
mouse_event(meFlags.MOUSEEVENTF_LEFTDOWN Or meFlags.MOUSEEVENTF_ABSOLUTE, tpnt, 0, New UIntPtr(Convert.ToUInt32(0)))
Threading.Thread.Sleep(tt)
mouse_event(meFlags.MOUSEEVENTF_LEFTUP Or meFlags.MOUSEEVENTF_ABSOLUTE, tpnt, 0, New UIntPtr(Convert.ToUInt32(0)))
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ax1 = 1050 'posizione X della barra blu "accedi con facebook"
ay1 = 290 'posizione Y della barra blu "accedi con facebook"
'Per determinare posizione e colore uso prima il prg "Colore pixel" in vb6
Dim hdc = GetWindowDC(0)
cc = GetPixel(hdc, ax1, ay1)
If cc = 10310967 Then
Timer1.Enabled = False
Timer2.Enabled = True
End If
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
hk = hk + 1
If hk = 2 Then
Dati1()
End If
If hk = 4 Then
Dati3()
hk = 0
Timer2.Enabled = False
End If
End Sub
End Class
e così funziona anche con windws-10 ed explorer-11