Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding question
#1
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?
[Image: fixedt.png]
Reply
#2
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
Reply
#3
(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.
[Image: fixedt.png]
Reply
#4
(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=""
........
My software company: Porosis Software
Games: Terrantula
Apps: Mathanasis, ColorGrabber
Reply
#5
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with coding jerrojack 1 884 12-29-2011, 03:27 AM
Last Post: AceInfinity
  Coding-Central.net - Coding, cracking and webmastering. w00pz 5 2,448 09-02-2011, 01:43 PM
Last Post: AceInfinity
  Help Coding A Downloader? Fragma 9 3,436 08-25-2011, 06:10 PM
Last Post: LiveModz
  .Net Coding Challenge #5 iCrack 18 5,944 05-21-2011, 12:49 AM
Last Post: thanasis2028
  [TUT]Improve your Coding[VB] ThePrinCe 10 1,833 05-07-2011, 06:40 PM
Last Post: Inventor

Forum Jump:


Users browsing this thread: 1 Guest(s)