Jump to content
bDyds

VB Autoclicker help

Recommended Posts

Salut, am nevoie de un autoclicker, asa ca m-am apucat sa fac eu unul in visual basic. Am citit niste tutoriale, toate bune si frumoase, am codul urmator:

Public Class Form1

Declare Sub mouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dx As Int32, ByVal dy As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32)


Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.F3 Then
Timer1.Start()
Else
If e.KeyCode = Keys.F4 Then
Timer1.Stop()
End
End If
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
KeyPreview = True
Me.TopMost = True
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Windows.Forms.Cursor.Position = New System.Drawing.Point(1344, 706)
mouse_event(&H2, 0, 0, 0, 0)
mouse_event(&H4, 0, 0, 0, 0)

End Sub

End Class

Am setat punctul pe care il vreau eu. Cand apas F3 incepe sa dea clickuri, insa problema este ca atunci cand apas pe F4 nu se opreste. Cauza este urmatoarea: eu cand dau clickuri, programul ramane alt-tab si nu mai inregistreaza pe ce taste se apasa. Mi-ar trebui cumva sa inregistreze tastele, chiar daca programul este minimizat sau ceva de genul. Am incercat cu Me.TopMost = True, dar fara succes.

Daca m-ar putea ajuta cineva, as fi foarte recunosacator.

Link to comment
Share on other sites

  • Active Members

Incearca sa folosesti asta:


Dim Hotkey As Boolean
Dim HotkeyB As Boolean
Hotkey = GetAsyncKeyState(Keys.F3)
If Hotkey = True Then
Timer1.Start()
End If

Hotkey = GetAsyncKeyState(Keys.F4)
If Hotkey = True Then
Timer1.Stop()
End If

In loc de ce ai folosit tu acolo pentru a defini F3 si F4.

Cu toate ca e un bad habbit sa folosesti functiile alea din VB (timer si keypress). Mai bine le implementezi tu pe ale tale.

Edited by MrGrj
Link to comment
Share on other sites

Incearca sa folosesti asta:


Dim Hotkey As Boolean
Dim HotkeyB As Boolean
Hotkey = GetAsyncKeyState(Keys.F3)
If Hotkey = True Then
Timer1.Start()
End If

Hotkey = GetAsyncKeyState(Keys.F4)
If Hotkey = True Then
Timer1.Stop()
End If

In loc de ce ai folosit tu acolo pentru a defini F3 si F4.

Multumesc mult pentru raspuns, asta am gasit si eu intre timp si s-a rezolvat. In cazul in care intereseaza pe cineva, o sa pun tot codul, intrucat MrGrj, din neatentie probabil, a uitat sa declare functia GetAsyncKeysState().

Public Class Form1

Declare Sub mouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dx As Int32, ByVal dy As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32)
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer


Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Windows.Forms.Cursor.Position = New System.Drawing.Point(1344, 706)
mouse_event(&H2, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 1)
End Sub

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Dim hotkey As Boolean
hotkey = GetAsyncKeyState(Keys.F3)
If hotkey = True Then Timer1.Start()
Dim hotkey1 As Boolean
hotkey1 = GetAsyncKeyState(Keys.F4)
If hotkey1 = True Then Timer1.Stop()
End Sub
End Class

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...