使用vbs打开多个选项卡并登录 [英] Using vbs to open multiple tabs and login

查看:147
本文介绍了使用vbs打开多个选项卡并登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我觉得有点厚颜无耻,这是我的第一篇文章,我为之道歉。


我一直在使用批处理文件来执行单个脚本按特定顺序打开选项卡。


批处理调用为每个独立URL修改的以下脚本的多次出现:

 WScript .Quit Main 

函数Main
设置IE = WScript.CreateObject(" InternetExplorer.Application"," IE_")
IE.Visible = True
IE .Navigate"http://www.example.com"
等待IE
使用IE.Document
WScript.Sleep 5000
.getElementByID(" username")。value =" MyID"
.getElementByID(" password")。value =" pass"
.getElementByID(" login")。s​​ubmit
End with
End Function

Sub Wait(IE)
Do
WScript。睡眠500
循环,而IE.ReadyState< 4和IE.Busy
Do
WScript.Sleep 500
Loop While IE.ReadyState< 4和IE.Busy
结束Sub

Sub IE_OnQuit
On Error Resume Next
WScript.StdErr.WriteLine"IE在脚本完成之前关闭。"
WScript.Quit
End Sub

虽然这在大多数浏览器上都能很好地为每个URL打开一个新选项卡并且填写凭证,每次在IE中运行脚本时,它都会打开一个新窗口。


我做了一些挖掘,发现这个漂亮的脚本检查IE的打开实例和相应地打开标签:

 Dim objShell,objShellWindows,objWindow,objIEApp 

设置objShell = CreateObject(" Shell.Application")
设置objShellWindows = objShell.Windows
For x = 0 to objShellWindows.Count - 1
设置objWindow = objShellWindows.Item(x)
On Error Resume Next
设置objIEApp = objWindow.Application
如果Err.Number = 0那么
objIEApp.Navigate2" http://www.example.com" ;, 2048
退出
结束如果
下一页

然而,尽我所能,我似乎无法将两个脚本中所需的部分组合在一起并添加GetElementbyID进入第二个sc以任何方式撕裂,虽然没有错误,但似乎被忽略了。反正有没有这样做?


提前感谢任何和所有回复。


干杯。



PS脚本必须以这种方式从批处理到可自定义的制表顺序运行。

解决方案

对不起,这是一个仅限VB.Net的论坛。请在此处发布:  http://social.msdn.microsoft.com/Forums/en -US /脚本/线程

Hello all, I feel kind of cheeky with this being my first post, for which I appologize.

I've been using a batch file to execute individual scripts to open tabs in a specific order.

The batch calls multiple occurrences of the following script modified for each independant URL:

WScript.Quit Main

Function Main
  Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
  IE.Visible = True
  IE.Navigate "http://www.example.com"
  Wait IE
  With IE.Document
WScript.Sleep 5000
    .getElementByID("username").value = "MyID"
    .getElementByID("password").value = "pass"
    .getElementByID("login").submit
  End With
End Function

Sub Wait(IE)
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy 
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy 
End Sub

Sub IE_OnQuit
  On Error Resume Next
  WScript.StdErr.WriteLine "IE closed before script finished."
  WScript.Quit
End Sub

While this works really well on most browsers opening a new tab for every URL and filling in the credentials, each time the script is run in IE, it opens a new window.

I did some digging and found this nifty script that checks for an open instance of IE and opens the tabs accordingly:

Dim objShell, objShellWindows, objWindow, objIEApp

Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
For x = 0 To objShellWindows.Count - 1
Set objWindow = objShellWindows.Item(x)
On Error Resume Next
Set objIEApp = objWindow.Application 
If Err.Number = 0 Then
 objIEApp.Navigate2 "http://www.example.com",2048 
 Exit for
End If
Next

However, try as I may, I can't seem to combine the parts I want from both scripts and adding the GetElementbyID into the 2nd script in any waywhatsoever, while it doesn't brong up an error, just seems to get ignored. Is there anyway to do this?

Thanks in advance to any and all replies.

Cheers.

PS the scripts have to be run this way from batch to make tab order customizable.

解决方案

I'm sorry, this is a VB.Net only forum. Please post here instead: http://social.msdn.microsoft.com/Forums/en-US/scripting/threads


这篇关于使用vbs打开多个选项卡并登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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