Hotkey in module help

Posts 1–5 of 5 · Page 1 of 1
Hotkey in module help Resolved
so titel says it all my hotkeys from module are not working heres the code just making a spammer and learning modules hotkeys

Code:
Module module1
  Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    Public Sub HotKey(ByVal hotkey As Boolean)
        hotkey = GetAsyncKeyState(Keys.Alt + Keys.S)
        If hotkey = True Then
            Form1.Timer1.Enabled = True
        End If
    End Sub
End Module
Code:
Public Class Form1
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        HotKey(True)
        SendKeys.Send(TextBox1.Text + "{enter}")
    End Sub

    Private Sub FButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FButton1.Click
        Timer1.Enabled = True
    End Sub

    Private Sub FButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FButton2.Click
        Timer1.Enabled = False
    End Sub
End Class
Change:

Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
To
Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Int16
Types have changed since VB6
If you are in Vb 2010 then yo can put this and it should be working :

this right under the public class:

<System.Runtime.InteropServices.DllImport("user32. dll")> _
Private Shared Function GetAsyncKeyState(ByVal vkey As System.Windows.Forms.Keys) As Short
End Function

and this in the timer private sub :

Dim Hotkey As Boolean
Hotkey = GetAsyncKeyState(Keys.F9)
If Hotkey = True Then
button1.PerformClick()
End If
thanks to both and yes i am using vb2010
Hey that's right with that comments
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?