我一直在为学校制作剧本,但我遇到了一些问题...... 如果我的脚本">"显示错误。 完成错误: 行:26 查尔:14 错误:语法错误
' Macro starter script -- basically for any teachers or students to understand and or improve my script.
'oShell.AppActivate("Paint"); // Set focus to a program
'WScript.Sleep(500); // Delay for 1/2 second
'oShell.Run("notepad c:\\temp\\somefile.txt", 1, false); // launch a program
'----------------------------- can add ,2 to run minimized, true=wait for exit
'oShell.SendKeys("%F"); // Alt+F ----- SendKeys strings to jog my memory
'oShell.SendKeys("^C"); // Ctrl+C
'oShell.SendKeys("{ENTER}"); // Send Enter key (also tilde {~} )
'oShell.SendKeys("{{TAB} 2"); // Send Tab key twice )
'oShell.SendKeys(" "); // Send a space
'var nResult= oShell.Popup("Do you want to continue?", 0, "My Macro", 4+32 );
'if ( nResult==6 ) { // 6=Yes, 7=No,
' WScript.Echo( "you said 'Yes!'" );
'}
'WScript.Echo( "done!" );
'Script Starts Here
var oShell = WScript.CreateObject("WScript.Shell")
WScript.Echo( "Script made by Joshua Hughes" )
var sResult = oShell.Popup("Do you want to save all work and shut down?", 0, "Shutdown", 4+32)
>if ( sResult==6 ) {
WScript.Echo( "Starting, do not press any buttons or click!" )
oShell.AppActivate("Word");
WScript.Sleep(500);
oShell.SendKeys("^S");
oShell.SendKeys("{ENTER}");
WScript.Sleep(500);
oShell.SendKeys("%F4")
oShell.AppActivate("Notepad");
WScript.Sleep(500)
oShell.SendKeys("^S");
oShell.SendKeys("{ENTER}");
WScript.Sleep(500);
oShell.SendKeys("%F4")
oShell.AppActivate("Powerpoint");
WScript.Sleep(500)
oShell.SendKeys("^S");
oShell.SendKeys("{ENTER}");
WScript.Sleep(500);
oShell.SendKeys("%F4")
oShell.AppActivate("Paint");
WScript.Sleep(500)
oShell.SendKeys("^S");
oShell.SendKeys("{ENTER}");
WScript.Sleep(500);
oShell.SendKeys("%F4")
end
]
WScript.Echo( "Program Complete! Shutting Down..." )
'Script Ends Here
故事: 我已经完成了我的评估,一个电子杂志,在我的高中八年级,我一直在摆弄代码,我设法制作一个可视化的基本脚本保存所有文件,关闭它,然后关闭,脚本虽然我今天已经回家了,但我一直在扩大剧本,并增加了一些,例如经典'你确定'提示。但我的电脑不同意......
我补充说因为它说: '看起来您的帖子主要是代码;请添加更多详细信息。'
答案 0 :(得分:0)
>if ( sResult==6 ) {
'...
end
]
不是VBScript。正确的语法是
If sResult = 6 Then
'...
End If