|
Answer» The problem with VBScript is that it is not event driven. A script will not wait for a keypress and continue on with the code. There are a COUPLE ways to emulate the original getkey, neither very satisfactory.
Use the password dll:
Code: [Select]Set objPassword = CREATEOBJECT("ScriptPW.Password") WScript.StdOut.Write "Press a key: " strKey = objPassword.GetPassword() WScript.Echo WScript.Echo "Key pressed is: " & Mid(strKey, 1, 1)
Use STD i/o DEVICES:
Code: [Select]WScript.Echo "Press a Key: " WScript.StdOut.Write strMessage inputKey = WScript.StdIn.Read(1)
In both method, the enter key is required to get the character into the script. Method 1 hides the character as if it were a password; method 2 doesn't even do that. Both methods accept multiple characters, but only the first is used for processing.
Both scripts should be saved with a vbs extension and run from the command prompt as cscript scriptname.vbs Note: do not use wscript.
Good luck. second code was working but i think i vista dont have password dll but anyway thanks for help.
|