Показать полную графическую версию : [решено] Вопрос по GUICtrlCreateEdit
Добрый день!
Подстажите, как мне передать переменной в текстовом поле первую(или любую другую) строку, а не весь текст?
madmasles
12-10-2012, 16:43
HFShak,
Смотрите пример к функции_GUICtrlEdit_GetLine (http://autoit-script.ru/autoit3_docs/libfunctions/_guictrledit_getline.htm)()Кликните по функции.
Спасибо.
А подскажите, как написать цикл, чтобы данная функция возвращала переменной все не пустые строки в текстовом поле.
Например, я вставляю в текстовое поле имена ПК, а_GUICtrlEdit_GetLine() возвращала переменнов $p в функции Ping($p) значения не пустых строк.
madmasles
16-10-2012, 14:19
HFShak,
Попробуйте примерно так.#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GuiConstantsEx.au3>
$sText = 'google.ru' & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & 'mail.ru' & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & 'yandex.ru' & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf)
GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)('Test', 400, 300)
$nEdit = GUICtrlCreateEdit (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateEdit.htm)('', 2, 2, 394, 168)
GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)(-1, $sText)
$sText = ''
$nButton = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)('Ping', 150, 180, 100, 30)
GUICtrlSetState (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetState.htm)(-1, $GUI_FOCUS)
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)()
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)()
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $nButton
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $sText = ''
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $iCount = 0
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $aText = StringSplit (http://www.autoitscript.com/autoit3/docs/functions/StringSplit.htm)(StringStripCR (http://www.autoitscript.com/autoit3/docs/functions/StringStripCR.htm)(GUICtrlRead (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlRead.htm)($nEdit)), @LF (http://www.autoitscript.com/autoit3/docs/macros.htm#@lf))
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 1 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $aText[0]
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $aText[$i] Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
$iCount += 1
ConsoleWrite (http://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm)('String num ' & $iCount & @TAB (http://www.autoitscript.com/autoit3/docs/macros.htm#@tab) & $aText[$i] & @LF (http://www.autoitscript.com/autoit3/docs/macros.htm#@lf))
$sText &= $aText[$i] & @TAB (http://www.autoitscript.com/autoit3/docs/macros.htm#@tab) & 'Ping:' & Ping (http://www.autoitscript.com/autoit3/docs/functions/Ping.htm)($aText[$i]) & ' msec' & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
$aText = 0
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $sText Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
ConsoleWrite (http://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm)('Strings count: ' & $iCount & @LF (http://www.autoitscript.com/autoit3/docs/macros.htm#@lf))
GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($nEdit, StringTrimRight (http://www.autoitscript.com/autoit3/docs/functions/StringTrimRight.htm)($sText, 2))
$sText = ''
$iCount = 0
Else (http://www.autoitscript.com/autoit3/docs/keywords.htm#Else)
GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($nEdit, '')
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
GUICtrlDelete (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlDelete.htm)($nButton)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.