Numlock key pad not working vb.net textbox? - vb.net

I have noticed that my textbox will not accept numbers from the num lock key pad how do I allow this in vb.net?

There's no restriction I know of. Either you've not activated NUMLOCK (thus making the keys act like cursor keys) or something is intercepting them (some other program).
From a VB.NET application's point of view, a key pad key is as good as any other. To be extra sure, try what happens in Visual Studio when you enter numbers using the key pad.

Related

Check if a sequence of keys are pressed in vb.net?

Im not sure if this is possible but I am working on a small project where I would like to be able to enter in a specific sequence of keys and then something happens. Its purpose is to act as a sort of "password" to unlock additional functionality. Im thinking maybe I could store key presses in an array somehow and compare the array to another that has the same key presses in it already or something similar but im not sure on where to start.

How do I simulate/release keyboard keys?

I need a way to simulate keyboard keys if a certain condition is met, I also need to know if it's the simulated key that's currently pressed or the real key. This needs to work outside the main application.
This is how I would need it to work:
Dim UserDefinedKey As Keys = Keys.H
Do
If GetAsyncKeyState(UserDefinedKey) Then
Thread.Sleep(30)
'release the set key
Thread.Sleep(30)
'press/hold the set key once, continue the loop if the real key is still been held.
End If
Loop While GetAsyncKeyState(UserDefinedKey) '/ loop while real key is being held
'Real key is no longer held, release the simulated key press.
Any help would be greatly appreciated.
(This code is to automate certain things inside of a game which is why it needs to work outside the main application)
I have certain things in place to allow the user to set their own key, this was just a small example of what I need, it's just the keyboard simulating part i'm stuck with and determining if the real key is still pressed or not.
So sorry for the long wait... Simulating keyboard input via Window Messages turned out to be far much more complicated compared to simulating mouse input in the same way.
Anyway, I am finally done with it so here's a complete InputHelper class for simulating both mouse and keyboard input virtually via the mouse and keyboard input stream or via Window Messages.
Download at GitHub: https://github.com/Visual-Vincent/InputHelper/releases (source code is too long to be pasted in the answer)
Dim UserDefinedKey As Keys = Keys.H
'Using a regular While-loop is better since you won't need your If-statement then.
While InputHelper.Keyboard.IsKeyDown(UserDefinedKey)
Dim ActiveWindow As IntPtr = InputHelper.WindowMessages.GetActiveWindow()
Thread.Sleep(30)
InputHelper.WindowMessages.SendKey(ActiveWindow, UserDefinedKey, False) 'False = Key up.
Thread.Sleep(30)
InputHelper.WindowMessages.SendKey(ActiveWindow, UserDefinedKey, True) 'True = Key down.
End While
A little information about InputHelper's sub-classes:
InputHelper.Keyboard
Methods for handling and simulating physical keyboard input (i.e. input detected by GetAsyncKeyState()).
InputHelper.Mouse
Methods for handling and simulating physical mouse input.
InputHelper.WindowMessages
Methods for handling and simulating virtual keyboard and mouse input (i.e. input that is not detected by GetAsyncKeyState()).
Hope this helps!
You will need Windows API hooks for that (nothing for beginners), or third party library like MouseKeyHook

VB.Net, keep shift pressed, and release after certain function is done?

Is that possible?
I want to keep my shift pressed in an external application (such as fire fox)
and release it as I pressed it again,
I want it working just like the caps button.
to make it easier to understand,
maybe something like
shift is pressed
Keys.Shift.hold = true
and
shift is pressed again
Keys.shift.hold = false
Apologies in advance for the pseudocode; I don't know VB.net. If you're comfortable with C++, you can adapt code from this question, which I used as a reference.
You can use the SendInput Windows API. According to the function's description, it
Synthesizes keystrokes, mouse motions, and button clicks.
You will need to ensure your target program has a lower process integrity than yours - in other words, if your process isn't running as admin, don't try to feed events to an admin-level process - but since you mentioned Firefox I don't expect this to be an issue for you.
You'll want to set up a KEYBDINPUT structure like this:
wVk = VK_SHIFT
dwFlags = 0 (this will press a key. You'll want KEYEVENTF_KEYUP instead for releasing it.)
Then, set up an INPUT structure like this:
type = INPUT_KEYBOARD
ki = yourKeybdInputStruct
Now pass that whole INPUT structure to SendInput:
SendInput(1, &yourInputStruct, sizeof(yourInputStruct))
Alternately, you could try using the VB.net SendKeys class. There are some caveats that come with this class; most notably,
If your application is intended for international use with a variety of keyboards, the use of Send could yield unpredictable results and should be avoided.
Additionally, the official documentation says nothing about using a modifier key (Shift, Ctrl, Alt) by itself, nor does it appear to support holding a key down in the manner you describe, just sending a regular keystroke (keydown-keyup).
However, if you're willing to deal with those issues, this might work:
SendKeys.Send("+")

Microsoft VB.NET 2010 - Assigning a Key to start a process when the window is minimized

This is an auto talker that i created, but it isn't very convenient to click on start and stop when the text is being typed at 10 milliseconds. So i wanted to create a key that when pressed starts the auto typer, and also stops it. I have a box where the user can press a key to assign to start and stop the auto typing. What code would i put for clicking on assign? I want assign to: get key from textbox5.text and use it as the shortcut key to start spamming. The key would be pressed when the Interface for the spam bot is minimized, so i can't use "&Spambot" for S to be the shortcut key.
Any help would be appreciated.
Please click on the link below to see image
http://s16.postimg.org/6xdxtjvg5/Interface.png
I successfully used some methods to read the numkey state, started my stuff when it is turned on, and stop it when it is turned off again, maybe you will like that solution.
If Control.IsKeyLocked(Keys.NumLock) Then ...
your alternative would be to 1. use an keyDown event (i think it gave more information about pressed keys than key pressed event), then store it in a local variable
And finally using an external dll to figure out if any key is pressed anywhere in windows. And if, then compare if it is the correct key, and then trigger whatever you want to trigger.

How to give users a certain time to enter something? (VB.Net)

I'm making a speed game in VB.Net (Console Application) and users have a certain time to press a certain key. So how can I give the Console.ReadKey function a timeout without just waiting until a key was pressed?
You should use a timer. When the user selects the correct key you can disable it. If the user is to then choose a different key you can just reset it.