Weird Hotkey Glitch?

Posts 1–10 of 10 · Page 1 of 1
Weird Hotkey Glitch?
Here is the code i have for a form:
Code:
Public Class Form1
    Private Const MF_BYPOSITION = &H400
    Private Const MF_REMOVE = &H1000
    Private Const MF_DISABLED = &H2

    Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As IntPtr, ByVal nPosition As Integer, ByVal wFlags As Long) As IntPtr
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
    Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As IntPtr) As Integer
    Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As IntPtr) As Boolean

    Public Sub DisableCloseButton(ByVal hwnd As IntPtr)
        Dim hMenu As IntPtr
        Dim menuItemCount As Integer

        hMenu = GetSystemMenu(hwnd, False)
        menuItemCount = GetMenuItemCount(hMenu)
        Call RemoveMenu(hMenu, menuItemCount - 1, MF_DISABLED Or MF_BYPOSITION)
        Call RemoveMenu(hMenu, menuItemCount - 2, MF_DISABLED Or MF_BYPOSITION)
        Call DrawMenuBar(hwnd)
    End Sub

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        Label3.Text = TrackBar1.Value
        Label6.Text = TrackBar1.Value / 1000
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If CheckBox1.Checked = True Then
            Process.Start(Application.StartupPath & "\startupedit.exe")
            Timer1.Interval = TrackBar1.Value
            My.Settings.speed = TrackBar1.Value
            My.Settings.Save()
        Else
            Timer1.Interval = TrackBar1.Value
            My.Settings.speed = TrackBar1.Value
            My.Settings.Save()
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DisableCloseButton(Me.Handle)
        If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
"Computer Spammer Startup", Nothing) Is Nothing Then
            MsgBox("Normal startup, no startup event found", MsgBoxStyle******rmation, "Normal Startup")
            TrackBar1.Value = My.Settings.speed

        Else
            MsgBox("Startup commands...")
            TrackBar1.Value = My.Settings.speed
            Button2.Enabled = False
            Me.Hide()
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub

    Private Sub CheckBox12_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox12.CheckedChanged
        If CheckBox12.Checked = True Then
            NotifyIcon1.Visible = True
        Else
            NotifyIcon1.Visible = False
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If CheckBox4.Checked = True Then
            Form2.Show()
        ElseIf CheckBox7.Checked = False Then
            antivir.Show()
        ElseIf CheckBox9.Checked = True Then
            Process.Start(Application.StartupPath & "cd.vbs")
        End If
    End Sub

    Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
        Me.Show()
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.Checked = True Then
            CheckBox10.Checked = True
            CheckBox10.Enabled = False
        End If
        If CheckBox3.Checked = False Then
            CheckBox10.Enabled = True
        End If
    End Sub

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.A Then
            TextBox1.Text = e.KeyCode
        End If
    End Sub
End Class
now... if i have my hotkey code...
Code:
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.A Then
            TextBox1.Text = e.KeyCode
        End If
    End Sub
End Class
nothing happens :/

IDK How to fix this, i already tried GetAsyncKeyState...
Try using
Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal Vkey As Long) As Integer
Then use
Code:
If GetAsyncKeyState(Keys.A) Then
'Do code
End If
I know you have already tried but it's worth trying again
NextGen1 showed me a way to make hotkeys for my button.

[php] Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If (e.KeyCode = Keys.Enter) Then
Button1_Click(sender, e)
End If
End Sub

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If (e.KeyCode = Keys.Enter) Then
Button1_Click(sender, e)
End If
End Sub

Private Sub TextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown
If (e.KeyCode = Keys.Enter) Then
Button1_Click(sender, e)
End If
End Sub[/php]

Of course, just change it to what you want, it should work for you.
thats what i tried next... anyways i have solved the problem by making a hidden form and redoing the coding...
my code was:
Code:
end
W8 still dont work...
If your looking for a "cheapy" way of doing it, use buttons or a menu

Set the text with &

E&nd - will make it so if a user presses Alt + n it will end
etc etc etc

the above method should always work, your probally doing something wrong, make sure that code is in in KeyDown
it does work, but i need it to not be focused when it does it. i will try the E&nd meathod.
Almost all components have a keydown, add it to your Form Keydown, Textbox keydowns and etc...
I NEED IT TO WORK WHEN IT IS NOT FOCUSED
.............
No need for caps....

I assumed you meant button or text-box,unfocus, I was explaining how to do it that way

Calm Down
.............

Look up Virtual Keys and System Wide Shortcuts , MSDN has plenty of material including a very detailed tutorial

Not Mine , Code Snippet form MSDN

Code:
Imports System.Runtime.InteropServices
 
' Press ALT+D to insert current date into where cursor is
Public Class Form2
 
    Public Const MOD_ALT As Integer = &H1 'Alt key
    Public Const WM_HOTKEY As Integer = &H312
 
    Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
    Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
   
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call RegisterHotKey(Me.Handle, 9, MOD_ALT, Keys.D)
    End Sub
 
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = WM_HOTKEY Then
            SendKeys.Send(DateTime.Now.Date.ToString("MM-dd-yyyy"))
        End If
        MyBase.WndProc(m)
    End Sub
 
    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Call UnregisterHotKey(Me.Handle, 9)
    End Sub
 
End Class
Use this concept to achieve your goals,
^thanks buttons says all XD
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us