I'm trying a PoC where in I'm trying to authenticate a user based on their HID card value. I don't have any specific API for the reader. The reader outputs plain number of the card by keyboard emulation.
The PoC permits a user to authenticate through username/password or through HID proxy card. To simplify things I wanted to use a hidden TextBox to which the value from HID is read and a corresponding webservice is triggered from TextChanged event.
I was unable to do so. Can anyone advice how this can be done, I'm very new to .Net environment.
Using that version of the reader device (the one with the keyboard emulation) you will need some form of text input control (e.g. a TextBox) to capture the text that the virtual keyboard sends. The problem with your approach of using a hidden TextBox is that it won't get the focus while the virtual keyboard "types" the card ID.
So you would need to intercept the KeyDown event in whatever UI element has focus while you expect the card ID. For instance if you have an window and no TextBox (or other element that consumes KeyPress events) has the focus, you could try to intercept the KeyPress event at the window level:
<Window ...
KeyDown="onKeyDownHandler"
>
The corresponding handler method would look like this:
private void onKeyDownHandler(object sender, KeyEventArgs e) {
// e.Key will give you the pressed key
}
So using this handler you should be able to collect all virtual key presses that are sent by the RFID reader. So all you would need to do is collect them and translate them into characters.
UPDATE:
This product leaflet suggests that the virtual keyboard version of the reader can configured to add keystrokes before and after the card ID. So you might be able to detect and mask out the input sent from that RFID reader even if the focus is on the text input fields for username or password by adding a character/control keycode that cannot occur in a username/password before the card ID. Then you could intercept the KeyDown event in both textboxes and -- upon receiving that control keycode -- you could consume all keystrokes sent by the virtual keyboard. By marking those key strokes with e.Handled = true;, you should be able to hide them from the text boxes.
As an alternative, you could use the serial version (e.g. USB virtual COM port) of that reader. If that's an option... You could then receive card IDs over a serial connection instead of the virtual keyboard. As a result, you would easily be able to distinguish between user input and RFID reader input as both would arrive on different communication interfaces.
Related
In a C++/winrt program with many xaml controls and panels I'm wondering if there is a recommended way to direct all keyboard input to one handler? And to restore that if the user temporarily uses a TextBox or other text input? I've found that handling keydown/keyup events in the MainPage works only until one uses the mouse to interact with any of the program's various Stackpanels, etc., after which it doesn't seem possible to restore focus to the MainPage. This is a program in which the keyboard is used for more than entering text in fields; it's used to trigger other events.
I have a barcode scanner. Each time this barcode scanner scanns something it first types ##1 and then the code it has read. I would like my app to set focus to a specific textbox whenever it detects the sequence ##1 regardless of what is selected/active when i am scanning. (for instance the focus could be on the form itself, or on an image, or in a table or whatever..)
The only way I have found is to use a global keyhook using getasynckeystate but its not good practice since most antivirus programs see it as a keylogger. I also do not need them to be detected when the program is not in focus.. only when in focus. Is there a proper way to detect all the Keys pressed while the application is active, that does not upset the antivirus programs?
I want to autofill a subject based on what the user types in to the subject field of an email. For example, the user starts typing T201234567 and the program will fill in the rest.
T201234567 SR9&54 Project title
I found the event for when a new email is created, but I would ideally like to have this program be as unobtrusive as possible, so it would only suggest titles, as the user is typing in something it recognizes.
So, is there an onKeyPress event for the subject field?
No, there is no such event. PropertyChange ("Subject") event will fire only when the user tabs out of the Subject edit box.
You can find the control's handle using Win API and intercept its Windows messages, but you cannot do that in VBA.
I'd like to create a listener in my app that will be notified when the user sets focus to a text input element in any application (essentially to be notified when there is a blinking text cursor in the frontmost app). I am trying to use this to notify an external hardware device that the user wants to input text, and to switch to text input mode.
I've been through NSObserver, the shared workspace notificationCenter, etc, and not found anything like this. Is it possible?
I suppose I could try constantly polling the current focus object, but I'd rather have a listener.
Searching found many answers along the lines of it depends on the device driver", but I don't think that it's that way here.
I have a cheap & nasty RFID tag reader. You just have to open notepad, touch a tag to the read and its serial number appears in notepad (I have not tried it in Linux).
Anyhoo, how can I programatically capture this serial number in VB.net (20088 express)?
Seem it work in keyboard emulation.
You can try to create a simple form with a textbox and check if the serial number appears on it when the tag is read and then manage the textbox events to retrive the info and set the focus correctly.
This probably works using keyboard emulation. The reader is pretending (to the PC) to be a USB keyboard, and simply sending the keystrokes.
If so you could do various things to check the keyboard input in VB.net. For a quick-and-dirty test, I would simply create a blank form with a textbox, make sure the textbox has focus, and read a tag. If the text passes to the textbox then the RFID reader is just passing keystrokes in, and you can use the textbox events to read the data (remembering to set focus to the textbox when you expect input).
If your app needs to do something more sophisticated with the input keystrokes, or you don't want them appearing in the control, you can trap and handle the keystrokes as they happen - the standard KB article on how to do this is here: http://support.microsoft.com/kb/320583