用户登录
用户注册

分享至

用vbscript实现启用 Caps Lock (大写)键

  • 作者: 老婆孩子热炕头儿
  • 来源: 51数据库
  • 2021-08-09
问:
嗨,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.
软件
前端设计
程序设计
Java相关