用vbscript實現(xiàn)啟用 Caps Lock (大寫)鍵
更新時間:2007年04月07日 00:00:00 作者:
問:
嗨,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.
相關(guān)文章
Vbs腳本實現(xiàn)radmin終極后門代碼_刪除自身
在網(wǎng)上看到N多人做radmin后門,要導(dǎo)出注冊表而且還用被殺軟件K殺。所以本人把自己寫的腳本提供大家分享。比較實用,希望大家喜歡。2008-06-06
使用vbs腳本實現(xiàn)自動打字祝福與搞笑實現(xiàn)代碼
聽說抖音上流行一種用代碼做程序表白的東西,其實很多vbs愛好者喜歡玩的東西,這里為大家分享一下,需要的朋友可以參考下2019-09-09
使用腳本調(diào)用系統(tǒng)的關(guān)機對話框?qū)崿F(xiàn)代碼
以前有介紹如何使用命令行調(diào)用系統(tǒng)的關(guān)機對話框rundll32.exe shell32.dll #60,但是,上述方法會存在一問題,XP下無法正常使用該方法進行關(guān)機2012-05-05

