用vbscript实现启用 Caps Lock (大写)键
程序员文章站
2022-07-04 20:28:25
问: 嗨,scripting guy!i have a script where users ente...
问:
嗨,scripting guy!i have a script where users enter some information in an input box.the information needs to be entered in all-capital letters, so my instructions say, “please make sure the caps lock key is on before entering the information.”they don't always do that, however.is there a way to turn the caps lock key on and off using a script?
-- bw, medford, or
答:
hey, bw.we don't know of a way to turn the caps lock key on and off, but we do know a way to mimic the effect of having the caps lock key on.after all, the whole point of the caps lock key is to turn everything you type into uppercase letters.for example, you might type this:
this is my sentence.
but caps lock will make it appear on screen like this:
this is my sentence.
so how can we achieve the same affect in a script?简单:we just use the vbscript function ucase, which switches all the letters in a string to their uppercase equivalent.for example, here's a simple two-line script that gathers information from a user and then uses the ucase function to switch all the letters to uppercase when echoing the value to the screen:
strmessage = inputbox("please enter your message:")wscript.echo ucase(strmessage)
incidentally, the above script doesn't actually change the case of the letters in the string strmessage; it just displays them in uppercase.if you really want all the letters converted to uppercase, try this script instead:
strmessage = ucase(inputbox("please enter your message:"))wscript.echo strmessage
looks crazy, but it works.
for more information about the ucase function, see thevbscript 文档 on msdn.
嗨,scripting guy!i have a script where users enter some information in an input box.the information needs to be entered in all-capital letters, so my instructions say, “please make sure the caps lock key is on before entering the information.”they don't always do that, however.is there a way to turn the caps lock key on and off using a script?
-- bw, medford, or
答:
hey, bw.we don't know of a way to turn the caps lock key on and off, but we do know a way to mimic the effect of having the caps lock key on.after all, the whole point of the caps lock key is to turn everything you type into uppercase letters.for example, you might type this:
this is my sentence.
but caps lock will make it appear on screen like this:
this is my sentence.
so how can we achieve the same affect in a script?简单:we just use the vbscript function ucase, which switches all the letters in a string to their uppercase equivalent.for example, here's a simple two-line script that gathers information from a user and then uses the ucase function to switch all the letters to uppercase when echoing the value to the screen:
strmessage = inputbox("please enter your message:")wscript.echo ucase(strmessage)
incidentally, the above script doesn't actually change the case of the letters in the string strmessage; it just displays them in uppercase.if you really want all the letters converted to uppercase, try this script instead:
strmessage = ucase(inputbox("please enter your message:"))wscript.echo strmessage
looks crazy, but it works.
for more information about the ucase function, see thevbscript 文档 on msdn.
上一篇: 把vbscript发挥到它的极限应用之一(数组)!!!
下一篇: iOS常见的几个修饰词深入讲解