Что нового

[Элементы GUI] GUI оболочка для работы с Radmin

beliy

Продвинутый
Сообщения
372
Репутация
72
Версия AutoIt: 3.3.6.1[br /][br /]Описание: Как извесно, в Radmin'е нет функции сохранения паролей, что не совсем удобно, особенно когда обслуживаешь много разных пк с разными паролями... Вот собственно и хочу создать программу-оболочку для Radmin, которая будет хранить пароли в зашифрованом виде (шифровать умею), спрашивала пароль на запуск оболочки, а дальше как в обычном радмине, но не выбрасывает окошко ввода а автоматом соединяет... В принципе такой же GUI создать можно с помошью утилитки koda, реализовать отдельно для каждой операции без привязки к GUI тож не проблема, а вот Совместить всё в GUI опыта не хватает<img src="http://autoit-script.ru/Smileys/AutoIt_Smileys/embarrassed.gif" alt="" title="" onresizestart="return false;" id="smiley_1_embarrassed.gif" style="padding: 0pt 3px;" border="0"> [br /]Вот эталонная структура:

[br /]Примечания:[br /]в плане алгоритма то здесь всё просто... В настройках программы надо указать путь к радмину, а дальше просто запускаем его с разными ключами... [br /]Вот рабочий пример с которого я начинал:
Код:
#NoTrayIcon 
#include <File.au3>
#include <Array.au3>
Global $nameini =StringRegExpReplace(@ScriptName, '.{3}\z', 'ini') 
Global $ini = (@ScriptDir&"\"&$nameini)
Global $rpath = IniRead($ini, "rsetting", "rpath", "Не найдено")
Global $ip = IniRead($ini, "rsetting", "ip", "Не найдено")
Global $port = IniRead($ini, "rsetting", "port", "Не найдено")
Global $user = IniRead($ini, "rsetting", "user", "Не найдено")
Global $pass = IniRead($ini, "rsetting", "pass", "Не найдено")
If Not FileExists($ini) Or _FileCountLines($ini) < 1 Then
    MsgBox(16,"Ошибка!","Файл настроек не найден или повреждён")
    Exit
EndIf
run ($rpath&" /connect:"&$ip&":"&$port)
WinWait ( "Система безопасности Radmin:" , "" , 10 )
ControlSend("Система безопасности Radmin", "", "Edit1", $user)
ControlSend("Система безопасности Radmin", "", "Edit2", $pass)
Send("{ENTER}")
Exit


как видите этот скрипт, подразумевает что уже есть готовый файл настроек, с таким же названием как и скрипт, берёт оттуда переменные, запускает радмин с ключём, ждёт пока появится окно ввода вводит всё, соединяет... Для работы в режиме файл менеджера нужно добавить в конец ключ /file, если чата то /chat и т.д.[br /][br /]как пример контейнера для хранения паролей можно взять из исходника во вложении, также вкладываю скрипт по конфигурированию радмина там коде можно кое что взять... Хотел выложить исходники в виде текста но не влезаю в ограничения по символам :(

Буду очень признательным за любую помощь, как говорится с миру по модулю, получится нужный скрипт :smile: :whistle: :-[
На форуме новичок, так что сильно не пинайте, если гдето не дочитал правила :IL_AutoIt_1:
 
Автор
B

beliy

Продвинутый
Сообщения
372
Репутация
72
Вижу, тема не особо пользуется популярностью, ну что ж попробуем зайти из далека, так сказать путём эволюции :smile:
К скрипту в шапке хотел добавить окно создания конфига, т.э. запускается скрипт, если он не находит конфиг, то открывает окно в котором можно его создать...
выглядеть окно должно примерно так:

36e412273ebd.png


Вот один из вариантов, которые я пробовал для этого, но не работает((
собственно сам вариант скрипта:
Код:
#NoTrayIcon 
#include <File.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $nameini =StringRegExpReplace(@ScriptName, '.{3}\z', 'ini') 
Global $ini = (@ScriptDir&"\"&$nameini)
If Not FileExists($ini) Or _FileCountLines($ini) < 1 Then
    $Form1_1 = GUICreate("Radmin Starter - Новый конфиг", 304, 287, 207, 136)
    GUISetIcon("C:\Users\Администратор\Desktop\149.ico")
    $path_edit = GUICtrlCreateInput("Введите путь к Radmin", 88, 48, 169, 21)
    GUICtrlSetColor(-1, 0xC8C8C8)
    $port_edit = GUICtrlCreateInput("4899", 88, 112, 193, 21)
    $user_edit = GUICtrlCreateInput("IT", 88, 144, 193, 21)
    $pass_edit = GUICtrlCreateInput("Введите пароль", 88, 176, 193, 21)
    GUICtrlSetColor(-1, 0xC8C8C8)
    $rpath = GUICtrlCreateLabel("Путь:", 56, 56, 31, 17)
    GUICtrlSetTip(-1, "Путь к папке с Radmin'ом:")
    $ip_text = GUICtrlCreateLabel("IP Адрес:", 32, 88, 51, 17)
    $port_text = GUICtrlCreateLabel("Порт:", 56, 120, 32, 17)
    $user_text = GUICtrlCreateLabel("Пользователь:", 8, 152, 80, 17)
    $pass_text = GUICtrlCreateLabel("Пароль:", 40, 184, 45, 17)
    $OK_edit = GUICtrlCreateButton("Создать", 48, 232, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, '_edit_ok')
    $cancel_edit = GUICtrlCreateButton("Отмена", 184, 232, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, '_edit_exit')
    $Icon1 = GUICtrlCreateIcon("C:\Users\Администратор\Desktop\149.ico", -1, 8, 8, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
    $IPAddress_edit = _GUICtrlIpAddress_Create($Form1_1, 88, 80, 194, 21)
    _GUICtrlIpAddress_Set($IPAddress_edit, "192.168.0.1")
    $title = GUICtrlCreateLabel("Программа не обнаружила файл настроек...", 64, 8, 230, 17)
    $title1 = GUICtrlCreateLabel("Введите настройки и программа создаст новый", 48, 24, 250, 17)
    GUISetState(@SW_SHOW)
    $browse = GUICtrlCreateButton("...", 256, 48, 27, 21, $WS_GROUP)
    GUICtrlSetOnEvent($Browse,"_browse")
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $rpath
        EndSwitch
    WEnd
    Func _edit_exit()
        Exit
    EndFunc
    Func _edit_ok()
        IniWrite($ini, "rsetting", "rpath", $path_edit)
        IniWrite($ini, "rsetting", "ip", $IPAddress_edit)
        IniWrite($ini, "rsetting", "port", $port_edit)
        IniWrite($ini, "rsetting", "user", $user_edit)
        IniWrite($ini, "rsetting", "pass", $pass_edit)
        MsgBox(0,"Конфиг создан!","Файл настроек настроек успешно создан")
        Exit
    EndFunc
    Func _browse()
        $browse = FileSelectFolder("Choose a folder.", "",4)
    EndFunc
    WinClose  ( "Radmin Starter - Новый конфиг" )
EndIf
$rpath = IniRead($ini, "rsetting", "rpath", "Не найдено")
$ip = IniRead($ini, "rsetting", "ip", "Не найдено")
$port = IniRead($ini, "rsetting", "port", "Не найдено")
$user = IniRead($ini, "rsetting", "user", "Не найдено")
$pass = IniRead($ini, "rsetting", "pass", "Не найдено")
run ($rpath&" /connect:"&$ip&":"&$port)
WinWait ( "Система безопасности Radmin:" , "" , 10 )
ControlSend("Система безопасности Radmin", "", "Edit1", $user)
ControlSend("Система безопасности Radmin", "", "Edit2", $pass)
Send("{ENTER}")
Exit


p.s. Кнопку Browse пока не настраивал, главное заставить работать ядро скрипта, но если поможете встроить обзор, то буду весьма благодарен
 

Yuri

AutoIT Гуру
Сообщения
737
Репутация
282
Вот:
Код:
#include <File.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $nameini =StringRegExpReplace(@ScriptName, '.{3}\z', 'ini')
Global $ini = (@ScriptDir&"\"&$nameini)

If FileExists($ini) <> 0 Or _FileCountLines($ini) <> 0 Then
    MsgBox(64, "Ini", FileExists($ini)&">>> "&_FileCountLines($ini))
    $rpath = IniRead($ini, "rsetting", "rpath", "Не найдено")
    $ip = IniRead($ini, "rsetting", "ip", "Не найдено")
    $port = IniRead($ini, "rsetting", "port", "Не найдено")
    $user = IniRead($ini, "rsetting", "user", "Не найдено")
    $pass = IniRead($ini, "rsetting", "pass", "Не найдено")
    run ($rpath&" /connect:"&$ip&":"&$port)
    WinWait ( "Система безопасности Radmin:" , "" , 10 )
    ControlSend("Система безопасности Radmin", "", "Edit1", $user)
    ControlSend("Система безопасности Radmin", "", "Edit2", $pass)
    Send("{ENTER}")
    ;Exit
EndIf

$Form1_1 = GUICreate("Radmin Starter - Новый конфиг", 304, 287, 207, 136)   
    $path_edit = GUICtrlCreateInput("Введите путь к Radmin", 88, 48, 169, 21)
    GUICtrlSetColor(-1, 0xC8C8C8)
    $port_edit = GUICtrlCreateInput("4899", 88, 112, 193, 21)
    $user_edit = GUICtrlCreateInput("IT", 88, 144, 193, 21)
    $pass_edit = GUICtrlCreateInput("Введите пароль", 88, 176, 193, 21)
    GUICtrlSetColor(-1, 0xC8C8C8)
    $rpath = GUICtrlCreateLabel("Путь:", 56, 56, 31, 17)
    GUICtrlSetTip(-1, "Путь к папке с Radmin'ом:")
    $ip_text = GUICtrlCreateLabel("IP Адрес:", 32, 88, 51, 17)
    $port_text = GUICtrlCreateLabel("Порт:", 56, 120, 32, 17)
    $user_text = GUICtrlCreateLabel("Пользователь:", 8, 152, 80, 17)
    $pass_text = GUICtrlCreateLabel("Пароль:", 40, 184, 45, 17)
    $OK_edit = GUICtrlCreateButton("Создать", 48, 232, 75, 25, $WS_GROUP) 
    $cancel_edit = GUICtrlCreateButton("Отмена", 184, 232, 75, 25, $WS_GROUP)    
    $IPAddress_edit = _GUICtrlIpAddress_Create($Form1_1, 88, 80, 194, 21)
    _GUICtrlIpAddress_Set($IPAddress_edit, "192.168.0.1")
    $title = GUICtrlCreateLabel("Программа не обнаружила файл настроек...", 64, 8, 230, 17)
    $title1 = GUICtrlCreateLabel("Введите настройки и программа создаст новый", 48, 24, 250, 17)    
    $browse = GUICtrlCreateButton("...", 256, 48, 27, 21, $WS_GROUP)
    GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $cancel_edit
            _edit_exit()
        Case $OK_edit
            _edit_ok()
        Case $browse
            GUICtrlSetData($path_edit, _browse())    
    EndSwitch
WEnd
    
Func _edit_exit()
    Exit
EndFunc
    
Func _edit_ok()
    IniWrite($ini, "rsetting", "rpath", GUICtrlRead($path_edit))
    IniWrite($ini, "rsetting", "ip", _GUICtrlIpAddress_Get($IPAddress_edit))
    IniWrite($ini, "rsetting", "port", GUICtrlRead($port_edit))
    IniWrite($ini, "rsetting", "user", GUICtrlRead($user_edit))
    IniWrite($ini, "rsetting", "pass", GUICtrlRead($pass_edit))
    MsgBox(0,"Конфиг создан!","Файл настроек настроек успешно создан")
    Exit
EndFunc    
    
Func _browse()
    $message = "Укажите путь к Radmin"
    $PatchRadmin = FileSelectFolder("Choose a folder.", "",4)    
    If @error Then
        MsgBox(48,"Инфо","Папка не выбрана.")        
    Else    
        Return $PatchRadmin
    EndIf
EndFunc
 
Автор
B

beliy

Продвинутый
Сообщения
372
Репутация
72
Спасибо большое, что откликнулись... Но есть пару нюансов:
1. Скрипт даже при наличии конфига не запускает радмин с параметрами, а выкидывает снова окно ввода конфига
2. можно ли чтоб к строчке IniWrite($ini, "rsetting", "rpath", GUICtrlRead($path_edit)) дабавлялось \Radmin.exe, пробовал так
IniWrite($ini, "rsetting", "rpath", GUICtrlRead($path_edit&'\Radmin.exe'))
но не работает
3. можно ли поле пароля спрятать под точками или звёздочками

Заранее большое спасибо!!!
 

ura123

Новичок
Сообщения
1
Репутация
2
Вот рабочая запоминалка-вставлялка паролей:
Код:
#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.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(250)
    EndSelect
Until Not WinExists($title)

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
				ControlFocus($title2, '', 'Edit1')
				ControlSetText($title2, '', 'Edit1', GUICtrlRead($myedit1))
				ControlClick ( $title2, '','Button1')
				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.1' & @CRLF & 'Работает с ' & $version  & @CRLF & 'Ura, Pluscord')
EndFunc


Func ExitScript()
    Exit
EndFunc
Есть ограничение - не дожно быть квадратных скобок в названии соединения. :IL_AutoIt_1:
 

Yuri

AutoIT Гуру
Сообщения
737
Репутация
282
beliy
Исправил:
Код:
#include <File.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $nameini =StringRegExpReplace(@ScriptName, '.{3}\z', 'ini')
Global $ini = (@ScriptDir&"\"&$nameini)

If FileExists($ini) <> 0 Or _FileCountLines($ini) <> 0 Then
    
    $rpath = IniRead($ini, "rsetting", "rpath", "Не найдено")
    $ip = IniRead($ini, "rsetting", "ip", "Не найдено")
    $port = IniRead($ini, "rsetting", "port", "Не найдено")
    $user = IniRead($ini, "rsetting", "user", "Не найдено")
    $pass = IniRead($ini, "rsetting", "pass", "Не найдено")
    MsgBox(64, "CMD line", $rpath&" /connect:"&$ip&":"&$port) ; для контроля правильности составления командной строки    
    run ($rpath&" /connect:"&$ip&":"&$port)
    WinWait ( "Система безопасности Radmin:" , "" , 10 )
    ControlSend("Система безопасности Radmin", "", "Edit1", $user)
    ControlSend("Система безопасности Radmin", "", "Edit2", $pass)
    Send("{ENTER}")
    Exit ; раскомментировал
EndIf

$Form1_1 = GUICreate("Radmin Starter - Новый конфиг", 304, 287, 207, 136)   
    $path_edit = GUICtrlCreateInput("Введите путь к Radmin", 88, 48, 169, 21)
    GUICtrlSetColor(-1, 0xC8C8C8)
    $port_edit = GUICtrlCreateInput("4899", 88, 112, 193, 21)
    $user_edit = GUICtrlCreateInput("IT", 88, 144, 193, 21)
    $pass_edit = GUICtrlCreateInput("Введите пароль", 88, 176, 193, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) ; пароль при вводе - звездочки
    GUICtrlSetColor(-1, 0xC8C8C8)
    $rpath = GUICtrlCreateLabel("Путь:", 56, 56, 31, 17)
    GUICtrlSetTip(-1, "Путь к папке с Radmin'ом:")
    $ip_text = GUICtrlCreateLabel("IP Адрес:", 32, 88, 51, 17)
    $port_text = GUICtrlCreateLabel("Порт:", 56, 120, 32, 17)
    $user_text = GUICtrlCreateLabel("Пользователь:", 8, 152, 80, 17)
    $pass_text = GUICtrlCreateLabel("Пароль:", 40, 184, 45, 17)
    $OK_edit = GUICtrlCreateButton("Создать", 48, 232, 75, 25, $WS_GROUP) 
    $cancel_edit = GUICtrlCreateButton("Отмена", 184, 232, 75, 25, $WS_GROUP)    
    $IPAddress_edit = _GUICtrlIpAddress_Create($Form1_1, 88, 80, 194, 21)
    _GUICtrlIpAddress_Set($IPAddress_edit, "192.168.0.1")
    $title = GUICtrlCreateLabel("Программа не обнаружила файл настроек...", 64, 8, 230, 17)
    $title1 = GUICtrlCreateLabel("Введите настройки и программа создаст новый", 48, 24, 250, 17)    
    $browse = GUICtrlCreateButton("...", 256, 48, 27, 21, $WS_GROUP)
    GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $cancel_edit
            _edit_exit()
        Case $OK_edit
            _edit_ok()
        Case $browse
            GUICtrlSetData($path_edit, _browse())    
    EndSwitch
WEnd
    
Func _edit_exit()
    Exit
EndFunc
    
Func _edit_ok()
    Select
        Case GUICtrlRead($path_edit) = "0"    
            MsgBox(48,"Инфо","Укажите путь к Radmin.exe")
        Case GUICtrlRead($path_edit) = ""    
            MsgBox(48,"Инфо","Укажите путь к Radmin.exe")    
        Case _GUICtrlIpAddress_Get($IPAddress_edit) = "0.0.0.0"
            MsgBox(48,"Инфо","Укажите IP")
        Case GUICtrlRead($port_edit) = ""    
            MsgBox(48,"Инфо","Укажите порт")
        Case GUICtrlRead($user_edit) = ""    
            MsgBox(48,"Инфо","Укажите пользователя")
        Case GUICtrlRead($pass_edit) = ""    
            MsgBox(48,"Инфо","Укажите пароль")    
        Case Else
            IniWrite($ini, "rsetting", "rpath", GUICtrlRead($path_edit))
            IniWrite($ini, "rsetting", "ip", _GUICtrlIpAddress_Get($IPAddress_edit))
            IniWrite($ini, "rsetting", "port", GUICtrlRead($port_edit))
            IniWrite($ini, "rsetting", "user", GUICtrlRead($user_edit))
            IniWrite($ini, "rsetting", "pass", GUICtrlRead($pass_edit))
            MsgBox(0,"Конфиг создан!","Файл настроек настроек успешно создан")
            Exit
    EndSelect    
EndFunc    
    
Func _browse()
    $message = "Укажите путь к Radmin"    
    $PatchRadmin = FileOpenDialog("Укажите путь к Radmin.exe", @ProgramFilesDir, "Программы (*.exe)", 1) ; полный путь сразу к .exe вместо пути к папке
    If @error Then        
        MsgBox(48,"Инфо","Путь к Radmin не указан.")       
    Else    
        Return $PatchRadmin
    EndIf
EndFunc
 
Автор
B

beliy

Продвинутый
Сообщения
372
Репутация
72
Yuriy & ura123 Спасибо Вам огромное ребят!!! :beer: :ok:
скрипт любезно одолженый ura123 практически полностью удовлетворяет мои запросы, но так как даная затея делалась не только для удобства, но и что б на основе него разобраться с основами GUI интерфейса. Поэтому я решил усложнить немного скрипт и добавить более продвинутое трэй меню... в принципе сделать то сделал, но вот работает либо продвинутый трэй, либо запуск радмина... не поможете ли подружить? :-[

Модуль трэя закоментировал
Код:
#include <GUIConstants.au3>
#include <string.au3>
;~ #include <Constants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#NoTrayIcon
; следующий инклуд нужен для продвинутого меню, добавил его во вложения
#include <ModernMenuRaw.au3> 
If WinExists(@ScriptName) Then Exit
AutoItWinSetTitle(@ScriptName)
$version = 'Radmin Viewer Version 3.x 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)
#comments-start
$hTrayIcon = _TrayIconCreate("Radmin agent") 
 
_TrayIconSetClick(-1, 16) 
_TrayIconSetState() 
 
$nTrayMenu = _TrayCreateContextMenu() 

$Calc_TrayItem = _TrayCreateItem("Калькулятор") 
_TrayItemSetIcon(-1, "calc.exe", 0) 
 
$Reged_TrayItem = _TrayCreateItem("Редактор Реестра") 
_TrayItemSetIcon(-1, "regedt32.exe", 0) 
 
$CmdLine_TrayItem = _TrayCreateItem("Коммандная строка") 
_TrayItemSetIcon(-1, "cmd.exe", 0) 
 
$taskmgr_TrayItem = _TrayCreateItem("Диспетчер задач") 
_TrayItemSetIcon(-1, "taskmgr.exe", 0) 
 
$MSconf_TrayItem = _TrayCreateItem("Настройка системы") 
_TrayItemSetIcon(-1, "msconfig.exe", 0) 
 
$aboutsys  = _TrayCreateItem("О системе")
_TrayItemSetIcon(-1, "msinfo32.exe", 0)

$aboutitem  = _TrayCreateItem("О программе")
_TrayItemSetIcon(-1, "shell32.dll", 16783)
_TrayCreateItem("") 
_TrayItemSetIcon(-1, "", 0) 
 
$Exit_TrayItem = _TrayCreateItem("Выход") 
_TrayItemSetIcon(-1, "shell32.dll", 28) 
 
_SetTrayIconBkColor(0xC46200) 
_SetTraySelectBkColor(0xC44F2E) 
_SetTraySelectTextColor(0xFFFFFF) 
 
While 1 
    Switch GUIGetMsg()
        Case $aboutitem 
            Msgbox(64,$mytitle,'Версия 0.2beta' & @CRLF & 'Запоминалка паролей для Radmin' & @CRLF & 'Работает с ' & $version  & @CRLF & 'Сделано на Autoit')         
        Case $aboutsys 
            Run("msinfo32.exe")
        Case $taskmgr_TrayItem  
            Run("taskmgr.exe")
        Case $Calc_TrayItem 
            Run("Calc.exe") 
        Case $Reged_TrayItem 
            Run("regedt32.exe") 
        Case $CmdLine_TrayItem 
            Run("Cmd.exe") 
        Case $MSconf_TrayItem 
            Run("msconfig.exe") 
        Case $Exit_TrayItem 
            _TrayIconDelete($hTrayIcon) 
            Exit 
    EndSwitch 
WEnd 
#comments-end

Do
    $msg = TrayGetMsg()
    Select
        Case WinExists($title1)
            _WindowsPass()
            WinWaitClose($title1)
        Case WinExists($title2)
            _RadminPass()
            WinWaitClose($title2)
        Case Else
            Sleep(250)
    EndSelect
Until Not WinExists($title)

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
                ControlFocus($title2, '', 'Edit1')
                ControlSetText($title2, '', 'Edit1', 'IT')
                ControlFocus($title2, '', 'Edit2')
                ControlSetText($title2, '', 'Edit2', GUICtrlRead($myedit1))
                ControlClick ( $title2, '','Button2')
                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


P.S. В скрипте изначально был, добавлен модуль запоминания пароля виндовс, его можно убрать, т.к он в принципе не нужен, да и является не рабочим...
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
beliy,
У меня Radmin`a нет, поэтому функции не проверял. Чтобы работало меню, попробуйте так:
Код:
;...
Opt("TrayMenuMode", 1)

$hTrayIcon = _TrayIconCreate("Radmin agent")

_TrayIconSetClick(-1, 16)
_TrayIconSetState()

$nTrayMenu = _TrayCreateContextMenu()

$Calc_TrayItem = _TrayCreateItem("Калькулятор")
_TrayItemSetIcon(-1, "calc.exe", 0)

$Reged_TrayItem = _TrayCreateItem("Редактор Реестра")
_TrayItemSetIcon(-1, "regedt32.exe", 0)

$CmdLine_TrayItem = _TrayCreateItem("Коммандная строка")
_TrayItemSetIcon(-1, "cmd.exe", 0)

$taskmgr_TrayItem = _TrayCreateItem("Диспетчер задач")
_TrayItemSetIcon(-1, "taskmgr.exe", 0)

$MSconf_TrayItem = _TrayCreateItem("Настройка системы")
_TrayItemSetIcon(-1, "msconfig.exe", 0)

$aboutsys = _TrayCreateItem("О системе")
_TrayItemSetIcon(-1, "msinfo32.exe", 0)

$aboutitem = _TrayCreateItem("О программе")
_TrayItemSetIcon(-1, "shell32.dll", 16783)
_TrayCreateItem("")
_TrayItemSetIcon(-1, "", 0)

$Exit_TrayItem = _TrayCreateItem("Выход")
_TrayItemSetIcon(-1, "shell32.dll", 28)

_SetTrayIconBkColor(0xC46200)
_SetTraySelectBkColor(0xC44F2E)
_SetTraySelectTextColor(0xFFFFFF)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $aboutitem
			MsgBox(64, $mytitle, 'Версия 0.2beta' & @CRLF & 'Запоминалка паролей для Radmin' & @CRLF & 'Работает с ' & $version & @CRLF & 'Сделано на Autoit')
		Case $aboutsys
			Run("msinfo32.exe")
		Case $taskmgr_TrayItem
			Run("taskmgr.exe")
		Case $Calc_TrayItem
			_WindowsPass();Run("Calc.exe")
		Case $Reged_TrayItem
			Run("regedt32.exe")
		Case $CmdLine_TrayItem
			Run("Cmd.exe")
		Case $MSconf_TrayItem
			Run("msconfig.exe")
		Case $Exit_TrayItem
			_TrayIconDelete($hTrayIcon)
			Exit
	EndSwitch
WEnd
;...
Это кусок кода и самостоятельно работать не будет. Его надо в Ваш скрипт вставить.
 
Автор
B

beliy

Продвинутый
Сообщения
372
Репутация
72
2 madmasles трэй то работает, он и раньше работал, но проблема в том, что если моддуль трэя не закоментирован, но не работает автозаполнение и сохранения паролей - ф-ций, ради которых и создавался скрипт. Если же закоментировать так как я сделал в коде выше, то норм вводит и сохраняет... не пойму в чём затыка, почему не хочет работать и трэй и основной функционал... Помогите разобраться, плз :(
 
Автор
B

beliy

Продвинутый
Сообщения
372
Репутация
72
Вижу в предыдущим вопросом, возникла заминка, но ладно будем эволюционировать другим путём.
Полностью переделал меню трэя, теперь работает и основной функционал и трэй, но появилась не большая проблемка, как видим на скрине ниже, при нажатии на любой из пунктов, напртив его ставится галочка, и таких галочек может поставить хоть на все пункты меню, и убираются только после повторного нажатия на пункт, в идеале было бы поставить статические значки, вместо галок, которые не убираются, или хотя бы вобще убрать их появление...
586fff86956c.png


вот код:

Код:
#include <GUIConstants.au3>
#include <string.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#NoTrayIcon

If WinExists(@ScriptName) Then Exit
AutoItWinSetTitle(@ScriptName)
$version = 'Radmin Viewer Version 3.x 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)

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "_Tray_Main_Events")
TraySetClick(16)

$aboutitem  = TrayCreateItem("О программе")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")
TrayCreateItem('')

$Calc_TrayItem = TrayCreateItem("Калькулятор")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")
$Reged_TrayItem = TrayCreateItem("Редактор Реестра") 
TrayItemSetOnEvent(-1, "_Tray_Main_Events")
 
$CmdLine_TrayItem = TrayCreateItem("Коммандная строка") 
TrayItemSetOnEvent(-1, "_Tray_Main_Events")
 
$taskmgr_TrayItem = TrayCreateItem("Диспетчер задач") 
TrayItemSetOnEvent(-1, "_Tray_Main_Events")
 
$MSconf_TrayItem = TrayCreateItem("Настройка системы") 
TrayItemSetOnEvent(-1, "_Tray_Main_Events")

$run_TrayItem  = TrayCreateItem("Выполнить...")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")

$aboutsys  = TrayCreateItem("О системе")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")

$Exit_TrayItem = TrayCreateItem("Выход")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")
TraySetState()

Do
    $msg = TrayGetMsg()
    Select
        Case WinExists($title2)
            _RadminPass()
            WinWaitClose($title2)
        Case Else
            Sleep(250)
    EndSelect
Until Not WinExists($title)

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
                ControlFocus($title2, '', 'Edit1')
                ControlSetText($title2, '', 'Edit1', 'IT')
                ControlFocus($title2, '', 'Edit2')
                ControlSetText($title2, '', 'Edit2', GUICtrlRead($myedit1))
                ControlClick ( $title2, '','Button2')
                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 _Tray_Main_Events()
    Switch @TRAY_ID
        Case $aboutitem 
            Msgbox(64,$mytitle,'Версия 0.3beta' & @CRLF & 'Запоминалка паролей для Radmin' & @CRLF & 'Работает с ' & $version  & @CRLF & 'Сделано на Autoit')         
        Case $aboutsys 
            Run("msinfo32.exe")
        Case $taskmgr_TrayItem  
            Run("taskmgr.exe")
        Case $Calc_TrayItem 
            Run("Calc.exe") 
        Case $Reged_TrayItem 
            Run("regedt32.exe") 
        Case $CmdLine_TrayItem 
            Run("Cmd.exe") 
        Case $MSconf_TrayItem 
            Run("msconfig.exe") 
        Case $run_TrayItem 
            Send("#r")
        Case $Exit_TrayItem 
            Exit 
    EndSwitch
EndFunc


Просьба, отписывайте, по любому из известных вам вариантов... Заранее БОЛЬШОЕ спасибо!!!
 
Автор
B

beliy

Продвинутый
Сообщения
372
Репутация
72
Вижу предположений по поводу трэя так и не появилось, ну ладно я уже немного смерился с этим, но буквально недавно выяснил что скрипт не работает на 64 битный системах... Не подскажете в чём соль и как бороться? Заранее большое спасибо за любой из ответов...
 
Автор
B

beliy

Продвинутый
Сообщения
372
Репутация
72
C разрядностью разобрался, странно что никто носом не ткнул) А по поводу трэя до сих пор интересно возможные решения...
 

Guezt

Продвинутый
Сообщения
335
Репутация
82
beliy
а в чем проблема с треем ? ;)
Код:
#include <GUIConstants.au3>
#include <string.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>



Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)

$version = 'Radmin Viewer Version 3.x rus'
$mytitle = 'Агент Radmin Viewer:'

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "_Tray_Main_Events")
TraySetClick(16)

$aboutitem  = TrayCreateItem("О программе")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")
TrayCreateItem('')

$Calc_TrayItem = TrayCreateItem("Калькулятор")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")
$Reged_TrayItem = TrayCreateItem("Редактор Реестра")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")

$CmdLine_TrayItem = TrayCreateItem("Коммандная строка")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")

$taskmgr_TrayItem = TrayCreateItem("Диспетчер задач")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")

$MSconf_TrayItem = TrayCreateItem("Настройка системы")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")

$run_TrayItem  = TrayCreateItem("Выполнить...")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")

$aboutsys  = TrayCreateItem("О системе")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")

$Exit_TrayItem = TrayCreateItem("Выход")
TrayItemSetOnEvent(-1, "_Tray_Main_Events")
TraySetState()





Func _Tray_Main_Events()
    Switch @TRAY_ID
        Case $aboutitem
            Msgbox(64,$mytitle,'Версия 0.3beta' & @CRLF & 'Запоминалка паролей для Radmin' & @CRLF & 'Работает с ' & $version  & @CRLF & 'Сделано на Autoit')
			TrayItemSetState($aboutitem,4)
        Case $aboutsys
            Run("msinfo32.exe")
			TrayItemSetState($aboutsys,4)
        Case $taskmgr_TrayItem
            Run("taskmgr.exe")
			TrayItemSetState($taskmgr_TrayItem,4)
        Case $Calc_TrayItem
            Run("Calc.exe")
			TrayItemSetState($Calc_TrayItem,4)
        Case $Reged_TrayItem
            Run("regedt32.exe")
			TrayItemSetState($Reged_TrayItem,4)
        Case $CmdLine_TrayItem
            Run("Cmd.exe")
			TrayItemSetState($CmdLine_TrayItem,4)
        Case $MSconf_TrayItem
            Run("msconfig.exe")
			TrayItemSetState($MSconf_TrayItem,4)
        Case $run_TrayItem
            Send("#r")
			TrayItemSetState($run_TrayItem,4)
        Case $Exit_TrayItem
            Exit
    EndSwitch
EndFunc


While 1
	Sleep(100)
WEnd
 
Автор
B

beliy

Продвинутый
Сообщения
372
Репутация
72
Guezt Gutsy сказал(а):
beliy
а в чем проблема с треем ? ;)
В 9 посте написал, трей работает, но напротив пунктов меню ставятся галки как на скриншоте (т.э чисто косметитеская проблема)
 

Guezt

Продвинутый
Сообщения
335
Репутация
82
beliy
ты код то посмотрел который я тебе приложил, там решение ;)
 
Автор
B

beliy

Продвинутый
Сообщения
372
Репутация
72
Guezt Gutsy сказал(а):
beliy
ты код то посмотрел который я тебе приложил, там решение ;)

Сорь, не внимательно вносил изменения - всё работает...

Тему можно считать закрытой...
 

Maze

Новичок
Сообщения
1
Репутация
0
Здравствуйте, помогите пожалуйста
Есть несколько открытых окон РАдмина, нужен скрипт, который запрашивал бы от пользователя число и затем в каждом окне запускал бы несколько хоткеев. (Число нужно для сохранения файла с именем, содержащим этот номер)
 

BAHO

Новичок
Сообщения
1
Репутация
0
Здравствуйте. Как реализовать сохранение нескольких соединений в один ini, а при запуске приложения проста запрашивать какое соединение запустить?

Yuriy сказал(а):
Вот:
Код:
#include <File.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $nameini =StringRegExpReplace(@ScriptName, '.{3}\z', 'ini')
Global $ini = (@ScriptDir&"\"&$nameini)

If FileExists($ini) <> 0 Or _FileCountLines($ini) <> 0 Then
    MsgBox(64, "Ini", FileExists($ini)&">>> "&_FileCountLines($ini))
    $rpath = IniRead($ini, "rsetting", "rpath", "Не найдено")
    $ip = IniRead($ini, "rsetting", "ip", "Не найдено")
    $port = IniRead($ini, "rsetting", "port", "Не найдено")
    $user = IniRead($ini, "rsetting", "user", "Не найдено")
    $pass = IniRead($ini, "rsetting", "pass", "Не найдено")
    run ($rpath&" /connect:"&$ip&":"&$port)
    WinWait ( "Система безопасности Radmin:" , "" , 10 )
    ControlSend("Система безопасности Radmin", "", "Edit1", $user)
    ControlSend("Система безопасности Radmin", "", "Edit2", $pass)
    Send("{ENTER}")
    ;Exit
EndIf

$Form1_1 = GUICreate("Radmin Starter - Новый конфиг", 304, 287, 207, 136)   
    $path_edit = GUICtrlCreateInput("Введите путь к Radmin", 88, 48, 169, 21)
    GUICtrlSetColor(-1, 0xC8C8C8)
    $port_edit = GUICtrlCreateInput("4899", 88, 112, 193, 21)
    $user_edit = GUICtrlCreateInput("IT", 88, 144, 193, 21)
    $pass_edit = GUICtrlCreateInput("Введите пароль", 88, 176, 193, 21)
    GUICtrlSetColor(-1, 0xC8C8C8)
    $rpath = GUICtrlCreateLabel("Путь:", 56, 56, 31, 17)
    GUICtrlSetTip(-1, "Путь к папке с Radmin'ом:")
    $ip_text = GUICtrlCreateLabel("IP Адрес:", 32, 88, 51, 17)
    $port_text = GUICtrlCreateLabel("Порт:", 56, 120, 32, 17)
    $user_text = GUICtrlCreateLabel("Пользователь:", 8, 152, 80, 17)
    $pass_text = GUICtrlCreateLabel("Пароль:", 40, 184, 45, 17)
    $OK_edit = GUICtrlCreateButton("Создать", 48, 232, 75, 25, $WS_GROUP) 
    $cancel_edit = GUICtrlCreateButton("Отмена", 184, 232, 75, 25, $WS_GROUP)    
    $IPAddress_edit = _GUICtrlIpAddress_Create($Form1_1, 88, 80, 194, 21)
    _GUICtrlIpAddress_Set($IPAddress_edit, "192.168.0.1")
    $title = GUICtrlCreateLabel("Программа не обнаружила файл настроек...", 64, 8, 230, 17)
    $title1 = GUICtrlCreateLabel("Введите настройки и программа создаст новый", 48, 24, 250, 17)    
    $browse = GUICtrlCreateButton("...", 256, 48, 27, 21, $WS_GROUP)
    GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $cancel_edit
            _edit_exit()
        Case $OK_edit
            _edit_ok()
        Case $browse
            GUICtrlSetData($path_edit, _browse())    
    EndSwitch
WEnd
    
Func _edit_exit()
    Exit
EndFunc
    
Func _edit_ok()
    IniWrite($ini, "rsetting", "rpath", GUICtrlRead($path_edit))
    IniWrite($ini, "rsetting", "ip", _GUICtrlIpAddress_Get($IPAddress_edit))
    IniWrite($ini, "rsetting", "port", GUICtrlRead($port_edit))
    IniWrite($ini, "rsetting", "user", GUICtrlRead($user_edit))
    IniWrite($ini, "rsetting", "pass", GUICtrlRead($pass_edit))
    MsgBox(0,"Конфиг создан!","Файл настроек настроек успешно создан")
    Exit
EndFunc    
    
Func _browse()
    $message = "Укажите путь к Radmin"
    $PatchRadmin = FileSelectFolder("Choose a folder.", "",4)    
    If @error Then
        MsgBox(48,"Инфо","Папка не выбрана.")        
    Else    
        Return $PatchRadmin
    EndIf
EndFunc
 
Верх