Quisi usa l'api sendinput... anche io l'ho usata..
ti mostro il mio codice:
In un modulo:
-----------------------------
Type MOUSEINPUT
dx As Long
dy As Long
mouseData As Long
dwFlags As Long
dwtime As Long
dwExtraInfo As Long
End Type
Type INPUT_TYPE
dwType As Long
xi(0 To 23) As Byte
End Type
----------------
poi:
--------------------------------------
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, pInputs As INPUT_TYPE, ByVal cbSize As Long) As Long
Private Const INPUT_MOUSE = 0
Private Const INPUT_KEYBOARD = 1
Private Const INPUT_HARDWARE = 2
--------------------------------------------
Public Sub ClickDaMouse()
AppActivate ("Warrock") 'Nome Caption
Dim intX As Integer
Dim inputEvents(0 To 1) As INPUT_TYPE ' holds information about each event
Dim mouseEvent As MOUSEINPUT ' temporarily hold mouse input info
' Load the information needed to synthesize pressing the left mouse button.
mouseEvent.dx = 0 ' no horizontal movement
mouseEvent.dy = 0 ' no vertical movement
mouseEvent.mouseData = 0 ' not needed
mouseEvent.dwFlags = MOUSEEVENTF_LEFTDOWN ' left button down
mouseEvent.dwtime = 0 ' use the default
mouseEvent.dwExtraInfo = 0 ' not needed
' Copy the structure into the input array's buffer.
inputEvents(0).dwType = INPUT_MOUSE ' mouse input
CopyMemory inputEvents(0).xi(0), mouseEvent, Len(mouseEvent)
intX = SendInput(2, inputEvents(0), Len(inputEvents(0))) ' place the events into the stream
End Sub
__________________________________________________ __
Public Sub LeaveDaMouse()
AppActivate ("Warrock") 'Nome Caption
Dim intX As Integer
Dim inputEvents(0 To 1) As INPUT_TYPE ' holds information about each event
Dim mouseEvent As MOUSEINPUT ' temporarily hold mouse input info
' Do the same as above, but for releasing the left mouse button.
mouseEvent.dx = 0 ' no horizontal movement
mouseEvent.dy = 0 ' no vertical movement
mouseEvent.mouseData = 0 ' not needed
mouseEvent.dwFlags = MOUSEEVENTF_LEFTUP ' left button up
mouseEvent.dwtime = 0 ' use the default
mouseEvent.dwExtraInfo = 0 ' not needed
' Copy the structure into the input array's buffer.
inputEvents(1).dwType = INPUT_MOUSE ' mouse input
CopyMemory inputEvents(1).xi(0), mouseEvent, Len(mouseEvent)
' Now that all the information for the 2 input events has been placed
' into the array, finally send it into the input stream.
intX = SendInput(2, inputEvents(0), Len(inputEvents(0))) ' place the events into the stream
End Sub
-----------------------------------------
Alla fine poi per chiamarlo chiamo le 2 sub
però col gioco non funziona... non è che devo settare il focus sul gioco? se si.. COME SI FA?
Grazie Mille Dell'aiuto! Sto uscendo pazzo...