发送时出错(vbscript 中带有发送键的字符 [英] Error while sending ( character with sendkeys in vbscript

查看:26
本文介绍了发送时出错(vbscript 中带有发送键的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用 SendKeys 发送("或)"字符时出现以下错误.在我的 vbscript 中.

I am getting the following error when I try to send to send a "(" or ")" character using SendKeys .In my vbscript.

Invalid procedure call or argument

我的脚本:

Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 100
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Documents and Settings\Administrator\Desktop\readme.txt", 1)
Wshshell.SendKeys "!@#$%^&*()"
Do Until objFile.AtEndOfStream
    strCharacters = objFile.Read(1)

    WshShell.SendKeys strCharacters
Loop

当我尝试在循环之前发送("和)"时,它不会发送("和)",但没有显示错误并继续直到遇到另一个("字符并因错误而停止.

It does not send the "(" and ")" when I try to send them before the loop but shows no error and continues till a little further where it encounters another "(" character and stops with the error.

推荐答案

括号被认为是一个特殊字符,需要用大括号括起来.请参阅此链接了解更多详情.

Parenthesis are considered a special character and need to be surrounded in braces. See this link for more details.

Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 100
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Documents and Settings\Administrator\Desktop\readme.txt", 1)
Wshshell.SendKeys "!@#$%^&*{(}{)}"
Do Until objFile.AtEndOfStream
    strCharacters = objFile.Read(1)

    WshShell.SendKeys strCharacters
Loop

这篇关于发送时出错(vbscript 中带有发送键的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆