Показать полную графическую версию : [решено] получить значение из _GUICtrlComboBoxEx_Create
VNRed_OK
12-05-2015, 11:46
Есть небольшой скрипт, вот фрагмент:
#include <GUIConstants.au3>
#include <GUIComboBoxEx.au3>
$hMainGUI = GUICreate("123", 300, 150)
$B_ok = GUICtrlCreateButton("OK", 180, 18, 50, 20);OK
$1combo = _GUICtrlComboBoxEx_Create($hMainGUI,"Брх|Чеп|Леб|Б-Б|Нов", 110, 10, 60, 200, $CBS_DROPDOWNLIST);
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $B_ok ;OK
$C_R = GUICtrlRead($1combo)
If $C_R = "" Then
MsgBox(0,"ПУСТО","???",4)
Else
MsgBox(0,'',$C_R)
EndIf
EndSwitch
WEnd
есть ли способ получить значение текущего содержимого из вот этого, "расширенного" ComboBox?
Вот тут можно подсмотреть функции GuiComboBoxEx.au3 (https://github.com/forcedotcom/dataloader/blob/master/windows-dependencies/autoit/Include/GuiComboBoxEx.au3)
...
$C_index = _GUICtrlComboBoxEx_GetCurSel($1combo)
$C_array = _GUICtrlComboBoxEx_GetItem($1combo,$C_index)
$C_R = $C_array[0]
...
искал как одной функцией получить, но что-то не нашел, хотя наверняка есть..
VNRed_OK
12-05-2015, 13:20
Mike909, благодарствую. Попробую разобраться
madmasles
12-05-2015, 16:57
VNRed_OK,
Можно так.#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstants.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIComboBoxEx.au3>
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $sTxt
$hGUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)('ComboBoxEx', 300, 150)
$idBtn = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)('OK', 180, 18, 50, 20);OK
$hCombo = _GUICtrlComboBoxEx_Create (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlComboBoxEx_Create.htm)($hGUI, 'Брх|Чеп|Леб|Б-Б|Нов', 110, 10, 60, 200, $CBS_DROPDOWNLIST)
_GUICtrlComboBoxEx_SetCurSel (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlComboBoxEx_SetCurSel.htm)($hCombo, Random (http://www.autoitscript.com/autoit3/docs/functions/Random.htm)(0, 4, 1))
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) $idBtn
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) _GUICtrlComboBoxEx_GetItemText (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlComboBoxEx_GetItemText.htm)($hCombo, _GUICtrlComboBoxEx_GetCurSel (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlComboBoxEx_GetCurSel.htm)($hCombo), $sTxt) > 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
ConsoleWrite (http://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm)($sTxt & @LF (http://www.autoitscript.com/autoit3/docs/macros.htm#@lf))
Else (http://www.autoitscript.com/autoit3/docs/keywords.htm#Else)
ConsoleWrite (http://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm)('!Error' & @LF (http://www.autoitscript.com/autoit3/docs/macros.htm#@lf))
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
VNRed_OK
13-05-2015, 08:21
madmasles, Благодарствую. Просто замечательный вариант. Этого решения будет достаточно.
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.