我需要使用 VBS 腳本在記事本中輸入“。
我有這個代碼:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad"
wscript.sleep 500
WshShell.sendkeys "some "text""
但它顯示一個錯誤。
uj5u.com熱心網友回復:
您需要將里面的引號加倍,或者您可以使用 chr(34)
Text = "my ""example"" of doubled quotes"
Text = "use " & Chr(34) & "chr ()" & Chr(34) & " function"
uj5u.com熱心網友回復:
Set WshShell = WScript.CreateObject('WScript.Shell')
WshShell.Run 'notepad'
wscript.sleep 500
WshShell.sendkeys 'some "text"'
uj5u.com熱心網友回復:
這是一個示例,向您展示如何使用 "double quotes"
和'simple quotes'使用函式:
Option Explicit
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "notepad"
wscript.sleep 1500
WshShell.sendkeys "some "& DblQuote("Text in Double Quotes") & vbcrlf &_
" another example : " & vbcrlf &_
SimpleQuote("Text between simple Quotes")
'--------------------------------------------------------------------------------
Function DblQuote(str) : DblQuote = chr(34) & str & chr(34) : End Function
'--------------------------------------------------------------------------------
Function SimpleQuote(Str) : SimpleQuote = ChrW(39) & Str & ChrW(39) : End Function
'--------------------------------------------------------------------------------
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/398242.html
標籤:壳 脚本 发送密钥 wscript.shell
下一篇:用戶按回車逐行輸入
