salve vorrei eseguire una simulazione del left click del mouse a coordinate ben precise, e ho dfifficolta a fare cio protreste aiutarmi
salve vorrei eseguire una simulazione del left click del mouse a coordinate ben precise, e ho dfifficolta a fare cio protreste aiutarmi
Non esiste un metodo nativo; al massimo puoi arrangiarti con l'API mouse_event.
Amaro C++, il gusto pieno dell'undefined behavior.
nn so come fare ad esempio su vb6.0 ho risolto con delle api ma qui su vb.net nn so inserire le api
Usa i normali declare tenendo conto che i tipi di dato sono cambiati.
Amaro C++, il gusto pieno dell'undefined behavior.
qulache code simple nn ci ho capito niente
Per simulare il click basta chiamare SimulateClick passandole come argomento il punto (relativo allo schermo) da "cliccare". Per cliccare il pulsante Button1, ad esempio, basterà fare così:codice: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 Declare Sub mouse_event Lib "user32" (ByVal dwFlags As meFlags, ByVal Coords As Drawing.Point, ByVal dwData As Integer, ByVal dwExtraInfo As UIntPtr) Sub SimulateClick(ByVal Location As Drawing.Point) Dim trect As Drawing.Rectangle = Screen.GetBounds(Location) Dim tpnt As New Drawing.Point(65535.0 / trect.Width * Location.X, 65535.0 / trect.Height * Location.Y) mouse_event(meFlags.MOUSEEVENTF_MOVE Or meFlags.MOUSEEVENTF_ABSOLUTE, tpnt, 0, New UIntPtr(Convert.ToUInt32(0))) mouse_event(meFlags.MOUSEEVENTF_LEFTDOWN Or meFlags.MOUSEEVENTF_ABSOLUTE, tpnt, 0, New UIntPtr(Convert.ToUInt32(0))) mouse_event(meFlags.MOUSEEVENTF_LEFTUP Or meFlags.MOUSEEVENTF_ABSOLUTE, tpnt, 0, New UIntPtr(Convert.ToUInt32(0))) End Sub
Questo era l'approccio "forza bruta". Credo che si possa fare anche smanettando con i messaggi di Windows, ora ci do un'occhiata...codice:Dim pnt As Drawing.Point pnt = Me.PointToScreen(Button1.Location) SimulateClick(pnt)
Amaro C++, il gusto pieno dell'undefined behavior.
ma mi interessa lo spostamento e il click fuori dal form in tutto l'ambiente windows
Originariamente inviato da MItaly
Per simulare il click basta chiamare SimulateClick passandole come argomento il punto (relativo allo schermo) da "cliccare".
Amaro C++, il gusto pieno dell'undefined behavior.
E' possibile oltre che spostare il muose utilizzando la funzione SimulateClick anche ottene le coordinate di dove si trova il muose??
Grazie
Mille
io ho trovato questo codice..ma non so se funziona.,
Dim MyPointAPI As POINTAPI
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Sub Timer1_Timer()
l = GetCursorPos(MyPointAPI)
Label1.Caption = CStr(MyPointAPI.X) & ", " & CStr(MyPointAPI.Y)
End Sub
Il mondo si divide in due categorie: chi ha la pistola carica e chi no...