Allora....io sto creando un prog, che automatizza tutto, cioè io lo faccio partire e lui fa tutto da solo, ho fatto un contatore di secondi, che è questo:
-------------------------------------------------------
Dim tempo As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
If Command1.Caption = "Start" Then
Command1.Caption = "Stop"
Else
Command1.Caption = "Start"
End If
If Command1.Caption = "start" Then Exit Sub
inizio = GetTickCount
Do: DoEvents
tempotmp& = GetTickCount - inizio
Sleep (5)
Label2.Caption = Format$(tempotmp& \ 3600000, "00") & ":" & Format$(((tempotmp& - (tempotmp& \ 3600000) * 3600000)) \ 60000, "00") & ":" & Format$((tempotmp& - (tempotmp& \ 60000) * 60000) / 1000, "00.000")
Loop Until tempotmp& > 1000 * 15
End Sub
-----------------------------------------------------------
.....questo conta fino a 15 secondi e appena terminano i 15 secondi, clicca col sinistro del mouse su un punto che gli do io, con questo comando:
-----------------------------------------------------------
' DICHIARAZIONI
Type POINTAPI
x As Long
y As Long
End Type
Declare Function ScreenToClient Lib "user32" Alias "ScreenToClient" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
' click con i tasto sinistro
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
' CODICE
Dim handle as Long
Dim clickPosition as POINTAPI
clickPosition.x = 120
clickPosition.y = 300
' ottiene l'handle della finestra
handle = WindowFromPoint(120, 300);
'converte le coordinate in base alla finestra
ScreenToClient handle, clickPosition
'pressione del tasto sinistro del mouse
SenMessage handle, WM_LBUTTONDOWN, clickPosition.x, clickPosition.y
' rilascio del tasto sinistro del mouse
SenMessage handle, WM_LBUTTONUP, clickPosition.x, clickPosition.y
------------------------------------------------------------
.....poi, subito dopo il click fa un controllo del colore di un pixel.....insomma verifica se il colore che il pixel ha ora, è diverso da quello che aveva prima del click.....
------------------------------------------------------------
' Dichiarazioni
Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
'CODICE
Dim hDC as long
Dim color as long
' otteniamo l'handle al device context
hDC = GetDC(0)
'otteniamo il colore al punto specificato
color = GetPixel(hDC, 300, 200)
' IMPORTANTE rilasciamo l'handle al device context
ReleaseDC(0, hDC)
------------------------------------------------------------
.....se il colore del pixel è cambiato dopo il click, allora prosegui (ed esegue il codice che serve per spostare l'oggetto, che scrivo qua sotto, guardaci un attimo....che forse manca qualcosa :-)) ....altrimenti il programma si ferma qua!
------------------------------------------------------------
' dichiarazione
Const MK_LBUTTON = &H1
Type POINTAPI
x As Long
y As Long
End Type
Declare Function ScreenToClient Lib "user32" Alias "ScreenToClient" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
' click con i tasto sinistro
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
' CODICE
Dim handle as Long
Dim clickPosition as POINTAPI
clickPosition.x = 300
clickPosition.y = 200
' ottiene l'handle della finestra
handle = WindowFromPoint(120, 300);
'converte le coordinate in base alla finestra
ScreenToClient handle, clickPosition
'pressione del tasto sinistro del mouse
SenMessage handle, WM_LBUTTONDOWN, clickPosition.x, clickPosition.y
'spostamento
SenMessage handle, MK_LBUTTON, clickPosition.x, clickPosition.y
' rilascio del tasto sinistro del mouse
SenMessage handle, WM_LBUTTONUP, clickPosition.x, clickPosition.y
---------------------------------------------------------------------
l'ultimo codice non so se è giusto!....qualcuno riuscirebbe a sistemarmelo e a metterlo tutto in un codice solo? nel senso che venisse fuori un programma unico! xchè non riesco a capire come mettere la sintassi! perfavore![]()

Rispondi quotando
