bDyds Posted December 21, 2014 Report Posted December 21, 2014 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 SubEnd ClassAm 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. Quote
Active Members MrGrj Posted December 21, 2014 Active Members Report Posted December 21, 2014 (edited) Incearca sa folosesti asta:Dim Hotkey As BooleanDim HotkeyB As BooleanHotkey = GetAsyncKeyState(Keys.F3)If Hotkey = True ThenTimer1.Start()End IfHotkey = GetAsyncKeyState(Keys.F4)If Hotkey = True ThenTimer1.Stop()End IfIn 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 December 21, 2014 by MrGrj Quote
bDyds Posted December 21, 2014 Author Report Posted December 21, 2014 Incearca sa folosesti asta:Dim Hotkey As BooleanDim HotkeyB As BooleanHotkey = GetAsyncKeyState(Keys.F3)If Hotkey = True ThenTimer1.Start()End IfHotkey = GetAsyncKeyState(Keys.F4)If Hotkey = True ThenTimer1.Stop()End IfIn 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 SubEnd Class Quote
time4play Posted January 9, 2015 Report Posted January 9, 2015 Putin diferit dar sub aceeasi forma cum l-ai gasit la a 2-a incercare am reusit sa-l fac si eu. Merge perfect Quote