#include <IE.au3>
#include <File.au3>
Opt('MustDeclareVars', 1)
Opt('TrayMenuMode', 1)
Global $oIE, $iStart, $sNick
If WinExists(@ScriptName & '{[/@$@\]}') Then Exit
AutoItWinSetTitle(@ScriptName & '{[/@$@\]}')
$oIE = _IECreate()
If @error Then
MsgBox(16, 'Error', '_IECreate')
Exit
EndIf
HotKeySet('{Esc}', '_Exit');Esc - выход
$sNick = _Play_Fool($oIE)
If Not @error And $sNick <> -1 Then
MsgBox(64, 'Info', 'Авторизируйтесь и играйте с ' & $sNick)
Else
$oIE.Visible = False
HotKeySet('^{1}', '_Visible_IE'); Ctrl + 1 - скрыть или отобразить окно IE
$iStart = TimerInit()
While 1
If TimerDiff($iStart) >= 30000 Then ;30sec
$sNick = _Play_Fool($oIE)
If Not @error And $sNick <> -1 Then
$oIE.Visible = True
MsgBox(64, 'Info', 'Авторизируйтесь и играйте с ' & $sNick)
ExitLoop
Else
$iStart = TimerInit()
EndIf
EndIf
Sleep(50)
WEnd
EndIf
Func _Play_Fool(ByRef $o_Obj, $s_Rate = '1 RUB', $s_Type = '0')
Local $s_Url = 'http://igrun.com/?p=39', $o_Table, $o_Trs, $o_Ths, $o_Link, $s_Url_Obj, _
$s_Nick_Player, $s_String = 'Присоединиться', $s_String_Control, $f_Yes, $i_Error = 1, _
$s_TempFile, $i_PID
If Not IsObj($o_Obj) Then Return SetError(1)
For $i = 1 To 1
$s_Url_Obj = _IEPropertyGet($o_Obj, 'locationurl')
If @error Then ExitLoop
If $s_Url_Obj == $s_Url Then
_IEAction($o_Obj, 'refresh')
If @error Then ExitLoop
Else
_IENavigate($o_Obj, $s_Url)
If @error Then ExitLoop
EndIf
$o_Table = _IEGetObjById($o_Obj, 'gs')
If @error Then ExitLoop
$o_Trs = _IETagNameGetCollection($o_Table, 'tr')
If @error Or Not @extended Then ExitLoop
For $o_Tr In $o_Trs
If $o_Tr.bgColor <> '0' Then
$o_Ths = _IETagNameGetCollection($o_Tr, 'th')
If @error Or Not @extended Then ContinueLoop
$s_String_Control = ''
For $o_Th In $o_Ths
$s_String_Control &= $o_Th.innertext & '|'
If StringInStr($s_String_Control, $s_Rate & '|' & $s_String & '|' & $s_Type) Then
$o_Link = _IETagNameGetCollection($o_Tr, 'a', 0)
If @error Then ExitLoop 3
$f_Yes = True
ExitLoop 2
EndIf
Next
EndIf
Next
$i_Error = 0
Next
If $i_Error Then Return SetError(1)
If $f_Yes Then
$i_Error = 1
For $i = 1 To 1
$s_TempFile = _TempFile()
$i_PID = _Click_IE_Msg($s_TempFile)
If @error Then ExitLoop
_IEAction($o_Link, 'click')
If @error Then ExitLoop
_IELoadWait($oIE)
If @error Then ExitLoop
$s_Nick_Player = StringRegExpReplace($s_String_Control, '\|.*$', '')
$i_Error = 0
Next
If ProcessExists($i_PID) Then ProcessClose($i_PID)
If ProcessWaitClose($i_PID, 2) Then FileDelete($s_TempFile)
If $i_Error Then
Return SetError(1)
Else
Return $s_Nick_Player
EndIf
Else
Return -1
EndIf
EndFunc ;==>_Play_Fool
Func _Exit()
If IsObj($oIE) Then
_IEQuit($oIE)
EndIf
Exit
EndFunc ;==>_Exit
Func _Visible_IE()
If Not IsObj($oIE) Then Return
Local $f_Visible = _IEPropertyGet($oIE, 'visible')
$oIE.Visible = Not $f_Visible
EndFunc ;==>_Visible_IE
Func _Click_IE_Msg($s_File)
Local $h_File, $i_Pid_Process
Local $s_Script = "#NoTrayIcon" & @CRLF & _
"While 1" & @CRLF & _
"$hWin = WinGetHandle('[Title:Сообщение с веб-страницы; Class:#32770]')" & @CRLF & _
"If $hWin Then ControlClick($hWin, '', '[CLASS:Button; INSTANCE:1]')" & @CRLF & _;INSTANCE:1 - OK, INSTANCE:2 - Отмена
"Sleep(100)" & @CRLF & _
"WEnd"
$h_File = FileOpen($s_File, 2)
If $h_File = -1 Then Return SetError(1)
If Not FileWrite($h_File, $s_Script) Then Return SetError(1)
FileClose($h_File)
$i_Pid_Process = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $s_File & '"')
If Not $i_Pid_Process Then Return SetError(1)
Return $i_Pid_Process
EndFunc ;==>_Click_IE_Msg