[Help]Locked Hotkeys?

Posts 1–15 of 18 · Page 1 of 2
[Help]Locked Hotkeys?
Hi, I have Visual Basic 2008 Express Edition. I just started using it, but I think it's quite easy and pratic to manage. Ok the point is, I want to do a Hotkey that its locked, something like this:

Hotkey: 1 Text: Blah Blah

What I want is to the hotkey be always there, and be always 1. The text its for when you press 1 it appears on the chat, like and auto typer. Can someone help me in how to code this right?
Could you please rephrase that?

I couldn't understand you very well :\
Well... You know Auto Typer by MurGee? He has the hotkeys marked as 1-10. I know the code:

If e.keycode = Keys.A Then
(Under here you can make an event for example)
Msgbox ("Hello")

That A after the Keys. is the hotkeys right? If it is, if I choose for example Msgbox all I need to do is press A (in this case)?
[php]
If e.KeyCode = Keys.A Then
'Do something when A is Pressed
MsgBox ("The {a} Key has been pressed)

End If

[/php]



... Create a timer then do what nextgen1 said

Remember set timer interval to 125 and enabled to true
(125 means its not going on and off at the same time while clicking >.>)
Lol thanks! I already knew the timer trick but I'm doing some other stuff sooooo. But thanks! I pressed thanks BTW :P
Quote Originally Posted by qddW$#%^jtyjtyj View Post
... Create a timer then do what nextgen1 said

Remember set timer interval to 125 and enabled to true
(125 means its not going on and off at the same time while clicking >.>)
No. What nextgen posted gets into the keydown event.
Blubb is right, remember e = whatever we (or vb) sets e as , in this case is

[php]
e As System.Windows.Forms.KeyEventArgs
[/php]

So it makes sense it would be in a key event

if you place the same code under a button control or timer

e would be eventargs

and e.keycode is not a member of eventargs
If you need it to be a global hotkey (i.e you don't want it to only work when your form is focussed) you can use GetAsyncKeyState to check if the key has been pressed.

GetAsyncKeyState declaration:
[php]
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal tehkeyz0r as Int32) as Int16
[/php]

Its use (put this in a timer event with like a 100-200 ms interval)

[php]

Dim myHotkey As Boolean = GetAsyncKeyState(Keys.A)

If myHotkey Then
'do whatever you want when the A key is pressed'
MsgBox("OMG THE 'A' KEY WAS PRESSED MY GOD I LOVE J-DEEZY HE'S HELLA SEXY")
End If

[/php]

yeah...
Thanks for all the information guyss! And special thanks to J-Deezy ^^

("OMG THE 'A' KEY WAS PRESSED MY GOD I LOVE J-DEEZY HE'S HELLA SEXY") < very original xD
Timer_Tick

[php]If Getasynckeystate(Keys.A) then
msgbox("OMG THE 'A' KEY WAS PRESSED AND I DID NOT EVEN HAVE TO DECLARE A BOOLEAN EVERY TIMER TICK WHICH MAKES THE PROGRAM SLOWER AND BLUBB IS WAY MOAR AWZUM THAN JDEEZY PERIOD!")
end if[/php]

Also possible.

GetAsynckeystate returns a boolean.

If getasynckeystate(keys.a) <- if a key is pressed, return true

By default, a boolean is set to false.

Declaring a boolean every 100 ms will definetely waste more memory ^.-

So IF you actually declare one, which is useless btw, atleast make it outside the timer.
[php]If e.Keycode = Keys.NumPad1 Then
SendKeys.Send(TextBox11.Text)
End If[/php]

Thats the code I'm using on one of the text boxes for an Auto-typer... When I press Save or Play and this error shows up: 'Keycode' is not a member of 'System.EventArgs'. I also tried:

[php] If KeyNotFoundException = Keys.NumPad1 Then
SendKeys.Send(TextBox11.Text)
End If[/php]

Just to try, but it didn't really worked... What's wrong?
Use KeyDown event.

Furthermore, keydown only affects the control.

I.e. using keydown on textbox. Only if you focus the textbox you hit the hotkey in the according keydown event(textbox), the action will take affect. You don't want that. You want global hotkeys.

So read Deezy's/My post.

@2nd code, no, simply no.... If Exception = keys... o_O?!

Control-Wide:

[php] Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyData = Keys.Enter Then
MsgBox(TextBox1.Text)
End If
End Sub[/php]

You have probably tried the .Click event...

System-Wide:

Check the previous posts.
Hm ok I will try it. Lol I know the second code was stupid. But I was like O.o? And so I tried it... what a fail I see xD
Private Sub TextBox11_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox11.KeyDown ' <- important
If e.KeyData = Keys.Enter Then
MsgBox(TextBox1.Text)
End If
End Sub
Posts 1–15 of 18 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us