Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


Ragnazar, можете попробовать так:
читать дальше »
Код: Выделить весь код
Option Explicit

Const READYSTATE_COMPLETE = 4

Dim objIE
Dim objWindow

Dim boolDone
Dim strPassword


Set objIE = WScript.CreateObject("InternetExplorer.Application", "IE_")

With objIE
	.Navigate "about:blank"
	
	Do
		WScript.Sleep 100
	Loop Until Not .Busy And .ReadyState = READYSTATE_COMPLETE
	
	.AddressBar = False
	.MenuBar    = False
	.StatusBar  = False
	.ToolBar    = False
	
	With .Document
		.write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Strict//EN"">" & vbCrLf & _
				"<html>" & vbCrLf & _
				"	<head>" & vbCrLf & _
				"		<meta http-equiv='Content-Type' content='text/html; charset=windows-1251'>" & vbCrLf & _
				"		<meta http-equiv='Content-Language' content='ru'>" & vbCrLf & _
				"		<title>Input password</title>" & vbCrLf & _
				"		<style>" & vbCrLf & _
				"			body {" & vbCrLf & _
				"				margin: 1em 1em 1em 1em;" & vbCrLf & _
				"				color: MidnightBlue;" & vbCrLf & _
				"				background-color: LightSteelBlue" & vbCrLf & _
				"			}" & vbCrLf & _
				"		</style>" & vbCrLf & _
				"	</head>" & vbCrLf & _
				"	<body>" & vbCrLf & _
				"		<label for='sPassword' accesskey='P'>Enter <u>p</u>assword:</label>" & vbCrLf & _
				"		<input type='password' name='sPassword' id='sPassword' size='50'>" & vbCrLf & _
				"		<input type='button' value='OK' name='OK'>" & vbCrLf & _
				"		<input type='button' value='Отмена' name='Cancel'>" & vbCrLf & _
				"	</body>" & vbCrLf & _
				"</html>"
		
		.getElementsByName("OK").item(0).onclick     = GetRef("IEButtonClick")
		.getElementsByName("Cancel").item(0).onclick = GetRef("IEButtonClick")
		
		With .getElementByID("sPassword")
			.onKeyPress                             = GetRef("IEOnKeyPress")
			.focus
		End With
		
		Set objWindow = .parentWindow
		
		With .Body
			objWindow.resizeTo .scrollWidth + 25, .scrollHeight + 32
			objWindow.moveTo (objWindow.screen.availWidth - .offsetWidth) \ 2, (objWindow.screen.availHeight - .offsetHeight) \ 2
		End With
		
		Set objWindow = Nothing
		
		'.getElementByID("sPassword").focus
	End With
	
	.Visible = True
	
	boolDone = False
	strPassword = Empty
	
	Do
		WScript.Sleep 100
	Loop Until boolDone
	
	On Error Resume Next
	.Quit
	On Error Goto 0
End With

Set objIE = Nothing

If Not IsEmpty(strPassword) Then
	WScript.Echo "Password is [" & strPassword & "]"
Else
	WScript.Echo "Password is not entered"
End If

WScript.Quit 0
'=============================================================================

'=============================================================================
Sub IE_OnQuit
	boolDone = True
End Sub
'=============================================================================

'=============================================================================
Sub IEButtonClick
	Select Case Me.Name
		Case "OK"
			strPassword = objIE.Document.getElementByID("sPassword").Value
			boolDone = True
		Case "Cancel"
			boolDone = True
		Case Else
			' Nothing to do
	End Select
End Sub
'=============================================================================

'=============================================================================
Sub IEOnKeyPress
	Select Case Me.ownerDocument.parentWindow.event.keyCode
		Case 13
			strPassword = Me.Value
			boolDone = True
		Case 27
			boolDone = True
		Case Else
			' Nothing to do
	End Select
End Sub
'=============================================================================

Последний раз редактировалось Iska, 02-09-2012 в 11:01. Причина: Поправил оформление (выравнивание) кода

Это сообщение посчитали полезным следующие участники:

Отправлено: 10:52, 02-09-2012 | #2