Visual Basic - Autoclick en Visual Basic 6.0

Life is soft - evento anual de software empresarial
 
Vista:

Autoclick en Visual Basic 6.0

Publicado por Luis (1 intervención) el 22/08/2011 21:07:54
Saludos cordiales,

Hago este post para pedirles ayuda a programar un autoshot, consiste en que cuando el Crosshair (Retícula) se coloque rojo, se realize un disparo automáticamente. Tómando en cuenta que el Crosshair siempre se mantiene en el centro.

Este es un source que tengo (Parte es de internet y otra parte la coloque yo)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Option Explicit
Dim cont As Long
 
Private Type POINTAPI
 x As Long
 y As Long
End Type
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
 
Private Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move
Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Private Const MOUSEEVENTF_MOVE = &H1 ' mouse move
Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
Private Const MOUSEEVENTF_MIDDLEUP = &H40
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10
Private Declare Function GetMessageExtraInfo Lib "user32" () As Long
 
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Click(p As POINTAPI)
'p.X and p.Y in absolute coordinates
'Put the mouse on the point
 
'mouse_event MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_MOVE, p.x, p.y, 0, GetMessageExtraInfo()
'Mouse Down
mouse_event MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, GetMessageExtraInfo()
'Mouse Up
mouse_event MOUSEEVENTF_LEFTUP, p.x, p.y, 0, GetMessageExtraInfo()
End Sub
 
 
Private Sub Command1_Click()
    cont = cont + 1
    Command1.Caption = CStr(cont)
End Sub
 
Private Sub Form_Load()
 Timer1.Interval = 100
End Sub
 
Private Sub Timer1_Timer()
 Dim tPOS As POINTAPI
 Dim sTmp As String
 Dim lColor As Long
 Dim lDC As Long
 lDC = GetWindowDC(0)
 Call GetCursorPos(tPOS)
 lColor = GetPixel(lDC, tPOS.x, tPOS.y)
 Me.BackColor = lColor
 sTmp = Right$("000000" & Hex(lColor), 6)
 Me.Caption = "R:" & Right$(sTmp, 2) & " G:" & Mid$(sTmp, 3, 2) & " B:" & Left$(sTmp, 2)
If Right$(sTmp, 2) = "FF" And Mid$(sTmp, 3, 2) = "00" And Left$(sTmp, 2) = "00" Then
    Click tPOS
End If
 
End Sub


El problema, es que cuando la retícula toca al enemigo (Se coloca roja), en vez de realizar el click, la mira se mueve totalmente hacia abajo bruscamente

Desde ya, muchas gracias a todos :)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Autoclick en Visual Basic 6.0

Publicado por jcmg (518 intervenciones) el 23/08/2011 22:11:26
pienso que es esta linea y tPOS revisala detenidamente

If Right$(sTmp, 2) = "FF" And Mid$(sTmp, 3, 2) = "00" And Left$(sTmp, 2) = "00" Then
Click tPOS
End If
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar