I'm very new to VB, or coding in general, but I followed an Auto Clicker tutorial because I thought it would be very easy and good to start with. Everything works, except I'm not too sure on how to make a hotkey.
I have two buttons, "Begin" and "Stop." I want to assign F10 to Begin and F12 to Stop.
I have this code already:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
From what I know, you'll be needing a Timer to make the hotkey. But now, I'm totally confused. If anyone would like to see the source for more info, just post.
Also, how do I put in a picture in the background so my GUI looks better?
No timer needed , heres the code:
Code:
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = System.Windows.Forms.Keys.F12 Then
MsgBox("You Clicked F12")
End If
End Sub
Set the "KeyPreview" property to "True" on form1
If you cant see it use this code in the "Form1_load" event :
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
KeyPreview = True
End Sub
(12-29-2009, 01:58 PM)dunlop03 Wrote: [ -> ]No timer needed , heres the code:
Code:
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = System.Windows.Forms.Keys.F12 Then
MsgBox("You Clicked F12")
End If
End Sub
Set the "KeyPreview" property to "True" on form1
If you cant see it use this code in the "Form1_load" event :
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
KeyPreview = True
End Sub
Thanks it worked, but do you know how to make it passive? Meaning, is there a way to make the hotkeys work if the program is minimized?
Also, this might be easy. I have a "Clear" button. I'm wanting it to clear all of the text fields. I've tried searching but no luck.
(12-29-2009, 05:40 PM)ElephantShoe Wrote: [ -> ]1)Thanks it worked, but do you know how to make it passive? Meaning, is there a way to make the hotkeys work if the program is minimized?
2)Also, this might be easy. I have a "Clear" button. I'm wanting it to clear all of the text fields. I've tried searching but no luck.
1) to do that you will need the code you wrote at the start of this post. I can't help you though because I don't know the details.
2) You must set the text of each textbox to ""
Code:
textbox1.text=""
textbox2.text=""
........
Yes use the button click event to clear all the textboxes , labels etc.
Heres an example.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
textbox1.text = ""
Label1.Text = ""
End Sub