VBS帮助! [英] VBS HELP!

查看:78
本文介绍了VBS帮助!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个脚本,当我点击它时,它将:


1。打开Chrome


2。打开Connexus.com


3。问我是否需要它来登录我


4。输入我的用户名和密码


以下是我到目前为止的内容

设置WshShell = WScript.CreateObject(" WScript.Shell" ;)
fso = InputBox("验证您是系统管理员,请输入您的登录密码。")
if fso<> " Connexus"然后
lol = msgBox("你输入的密码不正确。",16,"错误")
wscript.Quit
如果
结束如果fso =" Connexus"然后

Dim oShell
设置oShell = CreateObject(" WSCript.shell")
oShell.run(" chrome.exe")

wscript.sleep 300
wshshell.sendkeys" c"
wscript.sleep 100
wshshell.sendkeys" o"
wscript.sleep 100
wshshell.sendkeys" n"
wscript.sleep 100
wshshell.sendkeys" n"
wscript.sleep 100
wshshell.sendkeys" e"
wscript.sleep 100
wshshell.sendkeys" x"
wscript.sleep 100
wshshell.sendkeys" u"
wscript.sleep 100
wshshell.sendkeys" s"
wscript.sleep 100
wshshell.sendkeys"。"
wscript.sleep 100
wshshell.sendkeys" c"
wscript.sleep 100
wshshell.sendkeys" o"
wscript.sleep 100
wshshell.sendkeys" m"
wscript.sleep 100
wshshell.sendkeys" "
wscript.sleep 100
wshshell.sendkeys" {BACKSPACE}"
wscript.sleep 100
wshshell.sendkeys" {ENTER}"
wscript.sleep 2000
MsgBox"你需要我为你登录吗?",4,"登录"
如果MsgBoxResult = vbYes然后
wshshell.sendkeys" u"
wscript.sleep 100
wshshell.sendkeys" s"
wscript.sleep 100
wshshell.sendkeys" e"
wscript.sleep 100
wshshell.sendkeys" r"
wscript.sleep 100
wshshell.sendkeys" n"
wscript.sleep 100
wshshell.sendkeys" a"
wscript.sleep 100
wshshell.sendkeys" m"
wscript.sleep 100
wshshell.sendkeys" e"
wscript.sleep 100
wshshell.sendkeys" 1"
wscript.sleep 100
wshshell.sendkeys" 2"
wscript.sleep 100
wshshell.sendkeys" 3"
wscript.sleep 100
wshshell.sendkeys" 4"
wscript.sleep 100
wshshell.sendkeys" 5"
wscript.sleep 100
wshshell.sendkeys" {TAB}"
wscript.sleep 300
wshshell.sendkeys" p"
wscript.sleep 100
wshshell.sendkeys" a"
wscript.sleep 100
wshshell.sendkeys" s"
wscript.sleep 100
wshshell.sendkeys" s"
wscript.sleep 100
wshshell.sendkeys" w"
wscript.sleep 100
wshshell.sendkeys" o"
wscript.sleep 100
wshshell.sendkeys" r"
wscript.sleep 100
wshshell.sendkeys" d"
wscript.sleep 100
wshshell.sendkeys" 1"
wscript.sleep 100
wshshell.sendkeys" 2"
wscript.sleep 100
wshshell.sendkeys" 3"
wscript.sleep 500
wshshell.sendkeys" {ENTER}"
wscript.sleep 100
其他
msgbox("你去!:)")
结束如果

这一直给我一个错误,请帮忙解决它:)谢谢

解决方案

是错误1到5还是更大? 它是发生在每一行还是刚刚开始?


你想做什么? 为什么你认为这可以通过Chrome完成?


SendKeys是一个非常古老且非常不可靠的API。 它被设计为rfro Windows 3.1并且从未更新为NT。


在使用SendKeys之前,您需要使用AppActivate。 您无法在屏幕上点击屏幕或使用键盘,否则它将失败。


WshShell.AppActivate"窗口标题"


http://msdn.microsoft.com/en -us /库/ 8c6yea83(v = vs.84)的.aspx


I'm trying to make a script that when I click it, it will:

1. Open Chrome

2. Open Connexus.com

3. Ask If I need it to log me in

4. Enter my username and password

Here's what I got so far

Set WshShell = WScript.CreateObject("WScript.Shell")
fso = InputBox("To verify that you the system administrator, please enter your login password.") 
if fso <> "Connexus" then 
lol=msgBox("The password you entered was incorrect.",16,"Error") 
wscript.Quit 
end if 
if fso = "Connexus" then 

Dim oShell 
Set oShell = CreateObject ("WSCript.shell") 
oShell.run ("chrome.exe") 

wscript.sleep 300
wshshell.sendkeys "c"
wscript.sleep 100
wshshell.sendkeys "o"
wscript.sleep 100
wshshell.sendkeys "n"
wscript.sleep 100
wshshell.sendkeys "n"
wscript.sleep 100
wshshell.sendkeys "e"
wscript.sleep 100
wshshell.sendkeys "x"
wscript.sleep 100
wshshell.sendkeys "u"
wscript.sleep 100
wshshell.sendkeys "s"
wscript.sleep 100
wshshell.sendkeys "."
wscript.sleep 100
wshshell.sendkeys "c"
wscript.sleep 100
wshshell.sendkeys "o"
wscript.sleep 100
wshshell.sendkeys "m"
wscript.sleep 100
wshshell.sendkeys " "
wscript.sleep 100
wshshell.sendkeys "{BACKSPACE}"
wscript.sleep 100
wshshell.sendkeys "{ENTER}"
wscript.sleep 2000
MsgBox "Do you need me to log in for you?",4,"Log In"
    if MsgBoxResult = vbYes then
	wshshell.sendkeys "u"
	wscript.sleep 100
	wshshell.sendkeys "s"
	wscript.sleep 100
	wshshell.sendkeys "e"
	wscript.sleep 100
	wshshell.sendkeys "r"
	wscript.sleep 100
	wshshell.sendkeys "n"
	wscript.sleep 100
	wshshell.sendkeys "a"
	wscript.sleep 100
	wshshell.sendkeys "m"
	wscript.sleep 100
	wshshell.sendkeys "e"
	wscript.sleep 100
	wshshell.sendkeys "1"
	wscript.sleep 100
	wshshell.sendkeys "2"
	wscript.sleep 100
	wshshell.sendkeys "3"
	wscript.sleep 100
	wshshell.sendkeys "4"
	wscript.sleep 100
	wshshell.sendkeys "5"
	wscript.sleep 100
	wshshell.sendkeys "{TAB}"
	wscript.sleep 300
	wshshell.sendkeys "p"
	wscript.sleep 100
	wshshell.sendkeys "a"
	wscript.sleep 100
	wshshell.sendkeys "s"
	wscript.sleep 100
	wshshell.sendkeys "s"
	wscript.sleep 100
	wshshell.sendkeys "w"
	wscript.sleep 100
	wshshell.sendkeys "o"
	wscript.sleep 100
	wshshell.sendkeys "r"
	wscript.sleep 100
	wshshell.sendkeys "d"
	wscript.sleep 100
	wshshell.sendkeys "1"
	wscript.sleep 100
	wshshell.sendkeys "2"
	wscript.sleep 100
	wshshell.sendkeys "3"
	wscript.sleep 500
	wshshell.sendkeys "{ENTER}"
	wscript.sleep 100
Else
	msgbox("There you go! :)")
End if

This keeps on giving me an error, please help fix it :) Thanks

解决方案

Is the error 1 to 5 or is it bigger?  Does it happen on every line or just in the beginning?

What are you trying to do?  Why do you think this can be done with Chrome?

SendKeys is a very old and very unreliable API.  It was designed rfro Windows 3.1 and never updated for NT.

Before using SendKeys you need to use AppActivate.  You cannot click on the screen or use the keyboard while this is running or it will fail.

WshShell.AppActivate "Window Title"

http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.84).aspx


这篇关于VBS帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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