首页 > 解决方案 > VBScript:第 1 行字符 1 中的无效字符 800A0408 编译错误

问题描述

你好,我是新手,它说这个[在此处输入图像描述][1]

[1]:https ://i.stack.imgur.com/9s5SW.png 这是脚本

do
wscript.sleep 100
wshshell.sendkeys “{CAPSLOCK}”
wshshell.sendkeys “{NUMLOCK}”
wshshell.sendkeys “{SCROLLLOCK}”
loop```

标签: scripting

解决方案


您的脚本中有智能引号。在编码时尽量避免它们。

将它们更改为直引号:

Debug.Print "Start"

Set wshshell = CreateObject("WScript.Shell")
ctr = 1
Do
   Debug.Print "Loop " & ctr
   wscript.Sleep 1000  ' one second
   wshshell.SendKeys "{CAPSLOCK}"
   wshshell.SendKeys "{NUMLOCK}"
   wshshell.SendKeys "{SCROLLLOCK}"
   ctr = ctr + 1
Loop

推荐阅读