|
要用IE作一个输入密码的登录窗口,可是总是无法让IE窗口激活至前台,总是在任务栏闪烁,
发送按键时灵时不灵,太不稳定,求教高手指点。
option explicit
Dim ObjWsh,objIe,StrIepw,flag
'Dim screenWidth,ScreenHeight,width,height
Set objIE = WScript.CreateObject("InternetExplorer.Application","Event_")
Set objWsh = WScript.CreateObject("wscript.shell")
'Const Readystate_complete = 4
With objIE
.MenuBar = 0 '不显示IE对象菜单栏
.StatusBar = 0 '不显示IE对象状态栏
.AddressBar = 0 '不显示IE对象地址栏
.ToolBar = 0 '不显示IE对象工具栏
'.FullScreen=0 '全屏化IE对象
.Height = 250 '设置IE对象高度
.Top = 250 '设置IE对象高度
.left = 650 '设置IE对象高度
.Width = 281 '设置IE对象宽度
' screenWidth = .document.parentWindow.screen.availWidth
' screenHeight = .document.parentWindow.screen.availHeight
' if .width>screenWidth then width=screenWidth
' if .height>screenHeight then height=screenHeight
' .Width = width
' .Height = height
' .left = Fix((screenWidth - width)/2)
' .top = Fix((screenHeight - height)/2)
.Visible = 1 '设置是否可见
.Resizable = 0 '设置IE对象大小是否可以被改动
.Navigate "about:blank" '设置IE对象默认指向的页面
.Document.Write "<HTML><title>Login form</title><BODY scroll='no'><br /><br /><center>Please input password:<br /><br /><input type='password' id='px' password value=''><br /><br />"
.Document.Write "<center><input type=BUTTON name=certain id=certain value=Confim>"
End With
Set objIE.Document.getElementById("certain").OnClick=GetRef("ClickBtn")
'Objwsh.sendkeys "(^{esc}m)"
'do while objIe.busy or objIe.ReadyState <> Readystate_Complete
' wscript.sleep 100
'Loop
shell.minimizeall
strIepw = ""
flag = true
WScript.Sleep 1500
Objwsh.sendkeys "%{TAB}"
'WScript.Sleep 1500
do while flag
if objwsh.appActivate("Login form - Internet Explorer") = true then
'Objwsh.sendkeys "{ENTER}"
flag = false
'Objwsh.sendkeys "% {TAB}"
''Objwsh.sendkeys "% {f4}"
Objwsh.sendkeys "{TAB}"
Objwsh.sendkeys "{TAB}"
else
flag = true
wscript.sleep 200
end if
loop
'Objwsh.sendkeys "abc"
' Set objIe.Document.Body.All.ok.OnClick = GetRef("OkClick") 'ok按钮的点击事件绑定"okClick"过程
Do
WScript.Sleep 200
Loop
Sub ClickBtn()
strIepw = objIE.Document.getElementById("px").Value
'if objIE.Document.getElementById("px").Value <> "9527" then
''If objIe.Document.Body.All.px.Value <> "123456" Then
'strIepw = "密码错误"
'Else
'strIepw = "密码正确"
'End If
if not isnull(strIePw) then msgbox strIepw
'objIe.Quit()
End Sub
Sub Event_OnQuit
'MsgBox strIepw, vbSystemModal
WScript.Quit
End Sub
'set kw = oIE.Document.getElementById("pwd")
'kw.value = "test"
'
'Do
' WScript.Sleep 200
'Loop
'
'Sub aaa
' Dim str
' str = oIE.Document.getElementById("pwd").Value & VbCrLf
'' str = str & oIE.Document.getElementById("input2").Value & VbCrLf
'' str = str & oIE.Document.getElementById("input3").Value
' WScript.Echo str
'End Sub
|
|