Masked Input() in Console
Masked Input() in Console
Does anyone know of a way to mask an Input() response in the console? Like in a string or input requestor where you can designate a mask (like all "*") to conceal a password?
Re: Masked Input() in Console

Code: Select all
If OpenConsole()
Print("Password: ")
Repeat
KeyPressed$ = Inkey()
If KeyPressed$ <> ""
Select KeyPressed$
Case #LF$, #CR$
Break
Case #BS$
If Pass$
Pass$ = Left(Pass$, Len(Pass$) - 1)
Print(#BS$ + " " + #BS$)
EndIf
Default
If KeyPressed$ > " "
Pass$ + KeyPressed$
Print("*")
EndIf
EndSelect
Else
Delay(20) ; Don't eat all the CPU time, we're on a multitask OS
EndIf
ForEver
PrintN("")
PrintN("Show: " + Pass$)
Input()
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Masked Input() in Console
That is EXACTLY what I need. Perfect. Thank you so much, mk-soft.
- Mindphazer
- Enthusiast
- Posts: 457
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Re: Masked Input() in Console
Works fine on Windows
But not on MacOS : #BS$ does NOT erase character
But not on MacOS : #BS$ does NOT erase character
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
...and unfortunately... Windows at work...