#include <GUIConstants.au3>
#include <string.au3>
;~ #include <Constants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#NoTrayIcon
If WinExists(@ScriptName) Then Exit
AutoItWinSetTitle(@ScriptName)
$version = 'Radmin Viewer Version 3.3.0. rus, работает с сервером второй версии'
$mytitle = 'Агент Radmin Viewer:'
$title = 'Radmin Viewer'
$title1 = 'Система безопасности Windows: '
$title2 = 'Система безопасности Radmin: '
$title1len = StringLen($title1)
$title2len = StringLen($title2)
$s_EncryptPassword = 'qa1w3xe6crfvl;jjkghvfhfd'
$sIni = @ScriptDir & '\' & 'RaAgent.ini'
;if not FileExists(@ScriptDir & '\Radmin.exe') Then
; MsgBox(0,@ScriptName,'Файл "' & @ScriptDir & '\Radmin.exe" не найден!' & @CRLF & 'Попробуйте скопировать "' & @ScriptName & '" в "' & @ProgramFilesDir & '\Radmin Viewer 3\ !')
; Exit
;Else
; Run('Radmin.exe')
; WinWait($title,'',10)
;EndIf
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)
$aboutitem = TrayCreateItem("О программе")
TrayItemSetOnEvent(-1,"ShowInfo")
TrayCreateItem('')
$exititem = TrayCreateItem("Выход")
TrayItemSetOnEvent(-1,"ExitScript")
TraySetState()
Do
$msg = TrayGetMsg()
Select
Case WinExists($title1)
_WindowsPass()
WinWaitClose($title1)
Case WinExists($title2)
_RadminPass()
WinWaitClose($title2)
Case Else
Sleep(1000)
EndSelect
;Until Not WinExists($title)
Until Not 1
Func _WindowsPass()
$auto = 0
$name = StringMid(WinGetTitle($title1), $title1len)
$pos = WinGetPos($title1)
$gui = GUICreate( $mytitle & $name,338,159,$pos[0] + 20,$pos[1] + 20)
GUICtrlCreateLabel( 'Имя пользователя:', 18,23,108,16)
GUICtrlCreateLabel( 'Пароль:', 18,57,59,16)
GUICtrlCreateLabel( 'Домен:', 18,91,59,16)
$sData = IniReadSection($sIni, $name)
If @error or not ($sData[0][0] = 3) Then
Dim $sData[4][2]
$sData[1][1] = ControlGetText( $title1,'', 'Edit1')
$sData[2][1] = ''
$sData[3][1] = ControlGetText( $title1,'', 'Edit3')
Else
$sData[2][1] = _StringEncrypt(0, $sData[2][1], $s_EncryptPassword)
$auto = 1
EndIf
$myedit1 = GUICtrlCreateEdit ( $sData[1][1], 137,20,173,23, 0)
$myedit2 = GuiCtrlCreateInput ( $sData[2][1], 137,55,173,23, $ES_PASSWORD)
$myedit3 = GUICtrlCreateEdit ( $sData[3][1], 137,89,173,23, 0)
$button1 = GUICtrlCreateButton ('OK', 83,125,75,23, $BS_DEFPUSHBUTTON)
$button2 = GUICtrlCreateButton ('Отмена', 180,125,75,23)
GUISetState()
Do
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case ($msg = $button1) or $auto
ControlFocus($title1, '', 'Edit1')
ControlSetText($title1, '', 'Edit1', GUICtrlRead($myedit1))
ControlFocus($title1, '', 'Edit2')
ControlSetText($title1, '', 'Edit2', GUICtrlRead($myedit2))
ControlFocus($title1, '', 'Edit3')
ControlSetText($title1, '', 'Edit3', GUICtrlRead($myedit3))
ControlClick($title1, '','Button2')
if $auto Then
_checkPassword($name,1)
Else
if _checkPassword($name) then
$sData = 'Login=' & GUICtrlRead($myedit1) & @LF & 'Password=' & _StringEncrypt(1, GUICtrlRead($myedit2), $s_EncryptPassword) & @LF & 'Domen=' & GUICtrlRead($myedit3)
IniWriteSection($sIni, $name, $sData)
EndIf
EndIf
ExitLoop
Case $msg = $button2
ExitLoop
Case Else
Sleep(10)
EndSelect
Until Not WinExists($title1)
GUIDelete()
EndFunc
Func _RadminPass()
$auto = 0
$name = StringMid(WinGetTitle($title2), $title2len) ;имя подключения
$pos = WinGetPos($title2)
$gui = GUICreate('Агент Radmin Viewer: ' & $name,345,85,$pos[0] + 20,$pos[1] + 20)
GUICtrlCreateLabel( 'Введите пароль:', 35,18,93,16)
$sData = IniReadSection($sIni, $name)
If @error or not ($sData[0][0] = 1) Then
Dim $sData[2][2]
$sData[1][1] = ''
Else
$sData[1][1] = _StringEncrypt(0, $sData[1][1], $s_EncryptPassword)
$auto = 1
EndIf
$myedit1 = GuiCtrlCreateInput ( $sData[1][1], 135,15,173,23, $ES_PASSWORD)
$button1 = GUICtrlCreateButton ('OK', 90,50,75,23, $BS_DEFPUSHBUTTON)
$button2 = GUICtrlCreateButton ('Отмена', 188,50,75,23)
GUISetState()
Do
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case ($msg = $button1) or $auto
$controlname = StringMid(ControlGetText($title2, '', 'Static1'),1,7)
if ($controlname='Введите') then ;диалог радмин 2.0
ControlFocus($title2, '', 'Edit1')
ControlSetText($title2, '', 'Edit1', GUICtrlRead($myedit1))
ControlClick ( $title2, '','Button1')
else
ControlFocus($title2, '', 'Edit1') ;диалог радмин 3.0
ControlSetText($title2, '', 'Edit2', GUICtrlRead($myedit1))
ControlClick ( $title2, '','Button2')
EndIf
if $auto Then
_checkPassword($name,1)
Else
if _checkPassword($name) then
$sData = 'Password=' & _StringEncrypt(1, GUICtrlRead($myedit1), $s_EncryptPassword)
IniWriteSection($sIni, $name, $sData)
EndIf
EndIf
ExitLoop
Case $msg = $button2
ExitLoop
Case Else
Sleep(10)
EndSelect
Until Not WinExists($title2)
GUIDelete()
EndFunc
Func _checkPassword($name,$delete = 0)
If WinWait('Информация о соединении', 'Неверный пароль', 2) Then
If $delete Then
If MsgBox(1,$mytitle,'Удалить запись ' & $name & '?') = 1 Then
IniDelete ($sIni,$name)
EndIf
EndIf
Else
Return 1
EndIf
EndFunc
Func ShowInfo()
Msgbox(64,$mytitle,'Версия 0.2' & @CRLF & 'Работает с ' & $version & @CRLF & 'Ura, Pluscord, слегка chaus')
EndFunc
Func ExitScript()
Exit
EndFunc