The question is that I have some HID devices that act as a keyboard (MSR, Barcode scaner, RFID reader) and I want to be able to read their input in my WPF application without the necessity for this to happen in say a text field in the application.
Is it possible to read from STDIN in a WPF application.
calling Console.ReadLine() returns null every ti开发者_运维知识库me.
You will need a console. Two routes:
Make the application type a Console application (console applications can have windows as well). This will ensure a console is created by Windows on startup (or it will run inside the parent's console if the parent has one).
Use P/Invoke to call
AllocConsole
. This has the advantage of your application (1) never inheriting a parent processes' console, and (2) application logic can determine if and when it is created.
精彩评论