I want to read the password(Text) input while keeping the "CapsLock = true/false" readout up to date while the user is typing in Console application C#
User is Typing
Show Capslock is on/off
is it need using threading or not??
Thank for watching thank for answer and thank for help me guys.. ty
That's weird, but possible.
First problem is that Console won't let you write something until user finish his input. So you won't be able to handle CapsLock press "on-the-fly" and notify user about its state change. Even from separate threads. But you can use MessageBox from
PresentationCore.dllorSystem.Windows.Forms.dlland show it independently.Second problem is that you can't properly handle CapsLock press as some sort of KeyPress event. So you need manually check and detect its state changes.
I've got things work with this example:
And from somewhere in code in need to call just
var password = PromptUserPassword();There is a lot of nuances with this code, such as you can just "ignore" shown MessageBox and keep switching CapsLock and then receive tonns of MessageBox'es.
That example provided just for familiarization. I highly recommend NOT to use this in real authorization purposes, and probably migrate into WPF or WindowsForms at least for proper implementations.