Opt('MustDeclareVars', 1)
Global $sLogin, $sPass
$sLogin = 'Proxy_'
$sPass = 'qwe1231353'
Local $sResponse, $sServerLink
; Авторизация
$sResponse = _HttpRequest('http://www.darkorbit.bigpoint.com', 'loginForm_default_username=' & $sLogin & '&loginForm_default_password=' & $sPass)
;_Notepad($sResponse)
If StringInStr($sResponse, 'Данное имя пользователя и/или пароль некорректны') Then
MsgBox(16, 'Ошибка', 'Данное имя пользователя и/или пароль некорректны')
Exit
Else
MsgBox(64, 'Внимание', 'Авторизация успешно пройдена')
EndIf
; <== Авторизация
; Выбор сервера
$sServerLink = StringRegExpReplace($sResponse, '(?s)(?i).+?<div id="instance_574".+?<a class="verweis" href="(.+?)">.+', '\1')
$sResponse = _HttpRequest($sServerLink, '', 'GET')
;_Notepad($sResponse)
If Not StringInStr($sResponse, 'ДОБРО ПОЖАЛОВАТЬ, КОСМИЧЕСКИЙ ПИЛОТ') Then
MsgBox(16, 'Ошибка', 'Ошибка выбора сервера')
Exit
Else
MsgBox(64, 'Внимание', 'Сервер успешно выбран')
EndIf
; <== Выбор сервера
Func _HttpRequest($sRequestURL, $sSendData, $sType='POST')
If $sType == 'GET' AND $sSendData <> '' Then
$sRequestURL &= '?' & $sSendData
$sSendData = ''
EndIf
Local $oHTTP = ObjCreate('WinHttp.WinHttpRequest.5.1')
$oHTTP.Open($sType, $sRequestURL)
$oHTTP.setTimeouts(5000, 5000, 15000, 15000)
$oHTTP.SetRequestHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
$oHTTP.SetRequestHeader('Accept-Language', 'ru')
$oHTTP.SetRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
$oHTTP.SetRequestHeader('User-Agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)')
$oHTTP.SetRequestHeader('Host', $sRequestURL)
$oHTTP.SetRequestHeader('Proxy-Connection', 'Keep-alive')
$oHTTP.Send($sSendData)
$oHTTP.WaitForResponse
Return $oHTTP.ResponseText
EndFunc
Func _Notepad($sText)
Local $hWin = WinGetHandle('[CLASS:Notepad]')
If $hWin == '' Then
Run('notepad.exe')
$hWin = WinWait('[CLASS:Notepad]')
EndIf
ControlSetText($hWin, '', 'Edit1', $sText)
WinActivate($hWin)
EndFunc