Все верно, просто как все это (IniWrite) преобразовать в GUI
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 293, 115, 192, 124)
$Input1 = GUICtrlCreateInput("", 12, 16, 273, 21)
$Button1 = GUICtrlCreateButton("Button1", 109, 64, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
IniWrite("D:\1.ini", "section1", "key1", GUICtrlRead($Input1) )
EndSwitch
WEnd
Все верно, просто как все это (IniWrite) преобразовать в GUI
GUICreate("Заголовок", 290, 201, 192, 124)
GUICtrlCreateLabel("Текст", 8, 48, 64, 27)
$Text = GUICtrlCreateInput("", 8, 80, 273, 21)
$Button1 = GUICtrlCreateButton("Записать", 104, 112, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
if GUICtrlRead($Text) <> '' Then
IniWrite('D:\1.ini', 'section', 'key', GUICtrlRead($Text))
ExitLoop
Exit
EndIf
EndSwitch
WEnd
$Text = InputBox('Заголовок', 'Текст', '')
if $Text <> '' Then IniWrite('D:\1.ini', 'section', 'key', $Text)
if @error Then Exit
Do
$Text = InputBox('Заголовок', 'Текст', '')
if $Text <> '' Then
IniWrite('D:\1.ini', 'section', 'key', $Text)
ExitLoop
Exit
EndIf
Until @error
GUICreate("Заголовок", 290, 201, 192, 124)
GUICtrlCreateLabel("Текст", 8, 48, 64, 27)
$Text = GUICtrlCreateInput("", 8, 80, 273, 21)
$Button1 = GUICtrlCreateButton("Записать", 104, 112, 75, 25)
GUISetState(@SW_SHOW)
Do
If GUIGetMsg() = $Button1 then
IniWrite('D:\1.ini', 'section', 'key', GUICtrlRead($Text))
Exit
EndIf
Until GUIGetMsg() = -3
Обновил вышеперечисленные примеры, теперь после записи в INI файл скрипт будет закрыватсякак можно добавить в скрипт автоматическое закрытие GUI при нажатие кнопки.
$Text = GUICtrlCreateInput("192.168.50.", 8, 80, 273, 21)
GUICreate("Подключение по IP", 290, 150, 500, 500)
GUICtrlCreateLabel("Введите адрес сервера:", 70, 48, 500, 27)
$Text = GUICtrlCreateInput("", 8, 80, 273, 21)
$Button1 = GUICtrlCreateButton("Сохранить", 104, 112, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
if GUICtrlRead($Text) <> '' Then
IniWrite(@ScriptDir&"\Server.ini", 'Configuration', 'Server', GUICtrlRead ($Text))
ExitLoop
Exit
EndIf
EndSwitch
WEnd
#Include <GuiIPAddress.au3>
$hgui=GUICreate("Подключение по IP", 290, 150, 500, 500)
GUICtrlCreateLabel("Введите адрес сервера:", 70, 48, 500, 27)
$Button1 = GUICtrlCreateButton("Сохранить", 104, 112, 75, 25)
$hIPAddress = _GUICtrlIpAddress_Create ($hgui, 90, 70)
_GUICtrlIpAddress_Set ($hIPAddress, "192.168.50.")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
if _GUICtrlIpAddress_Get($hIPAddress) <> '' Then
IniWrite(@ScriptDir&"\Server.ini", 'Configuration', 'Server', _GUICtrlIpAddress_Get($hIPAddress))
ExitLoop
Exit
EndIf
EndSwitch
WEnd
А что по Вашему она должна возвращать ?VladUs,
Пустая строка возвращает 0.0.0.0
если я правильно понял, имеется в виду, что сравнивать надо с 0.0.0.0 а не пустой строкой.А что по Вашему она должна возвращать ?
GUICreate("Подключение по IP", 290, 150, 500, 500)
GUICtrlCreateLabel("Введите адрес сервера:", 70, 48, 500, 27)
$Text = GUICtrlCreateInput("", 8, 80, 273, 21)
$Button1 = GUICtrlCreateButton("Сохранить", 104, 112, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
if GUICtrlRead($Text) <> '' Then
IniWrite(@ScriptDir&"\Server.ini", 'Configuration', 'Server', '192.168.50.' & GUICtrlRead ($Text))
ExitLoop
Exit
EndIf
EndSwitch
WEnd
закрывался автоматом
;...
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
ExitLoop
Case $Button1
If GUICtrlRead($Text) <> '' Then
IniWrite(@ScriptDir & "\Server.ini", 'Configuration', 'Server', '192.168.50.' & GUICtrlRead($Text))
ExitLoop
EndIf
EndSwitch
WEnd
;если больше не будете окно использовать
GUIDelete()
;или, если будете использовать
GUISetState(@SW_HIDE)
;...