@henriqueshb
I have got an idea it maybe the reason for the problem, just give it a try!!!
How do you execute the code?
I mean, if you click on a button in your main form, probably the cursor go to the game and the click by mouse_event is just transfer the focus from your form to the game window, so try to send left click twice
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Go to point 800, 300
SetCursorPos(800, 300)
' Simulate left click.
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub
or put the code in a timer event to be sure it will be executed when the game window has the focus.
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' Go to point 800, 300
SetCursorPos(800, 300)
' Simulate left click.
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub