Hack Forums
[.NET] How do I make a hotkey in Visual Basic? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] How do I make a hotkey in Visual Basic? (/showthread.php?tid=5476918)



How do I make a hotkey in Visual Basic? - TechniqueGott - Nov 27, 2016

I made a really simple autoclicker and now I want to make it that whenever I press f3 it starts and f4 it stops.

This is my code:

Public Class Form1
Private Declare Sub mouse_event Lib "user32" (ByVal dwflags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cbuttons As Long, ByVal dwwExtraInfo As Long)
Private Const mouseclickup = 4
Private Const mouseclickdown = 2
Dim test As Integer
Private Sub BtnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
Click.Start()
End Sub

Private Sub BtnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
Click.Stop()

End Sub

Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click
test = test + 1
Counter.Text = test
End Sub

Private Sub Click_Tick(sender As Object, e As EventArgs) Handles Click.Tick
mouse_event(mouseclickdown, 0, 0, 0, 0)
mouse_event(mouseclickup, 0, 0, 0, 0)
End Sub
End Class


* - OffCode - Nov 27, 2016

Code
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Integer

Code
Sub start()
        If GetAsyncKeyState(Keys.Space) Then
             'Do Something

End If
End Sub



* - TechniqueGott - Nov 27, 2016

(Nov 27, 2016 08:33 AM)MaguEXE Wrote:  
Code
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Integer

Code
Sub start()
        If GetAsyncKeyState(Keys.Space) Then
             'Do Something

End If
End Sub


Thanks!