带控制命令选择的Auto It Combo Box消失

时间:2014-10-08 10:54:04

标签: combobox autoit

我正在使用AutoIt并希望使用ControlCommand控制组合框。我可以更改值,但是当我跳转到下一个命令时,它将被重置。

我试过几种方法,

http://www.autoitscript.com/forum/topic/109893-combo-box-click-item/

但它不起作用。

$hComBo=ControlGetHandle("","","[CLASS:TComboBox; INSTANCE:6]")
$aList = _GUICtrlComboBox_GetListArray($hComBo)
;_ArrayDisplay($aList)
Select
Case $Baudrate=5
    ControlCommand($hWnd,"",$hComBo,"SelectString",$aList[7])
    MsgBox($MB_OKCANCEL," Info ", @error & " - Element: " & $aList[7])
    ;_GUICtrlComboBox_SetCurSel($hComBo,5)
    ;$iCode = $CBN_SELCHANGE
    ;$val = BitShift($iCode, -16)
    ;_SendMessage($hWnd, $WM_COMMAND, $val, $hComBo)
    ;MsgBox($MB_SYSTEMMODAL," Info ", "hWnd: "& $hWnd &"- WM-Command: "& $WM_COMMAND &"- val: " & $val  &"- hComBo: " &$hComBo)
    Sleep(3000)
    ;MsgBox($MB_OKCANCEL," Info ", $baudrate)
EndSelect    

Sleep(3000)我可以看到组合框中有正确的值,但在处理完下一个命令后它会消失。有任何想法吗?

1 个答案:

答案 0 :(得分:0)

有时需要在设置一个列表条目(source)后发送WM_COMMAND消息。但正如MSDN中所述,要发送的$wParam必须同时包含$iCodeControl-ID

要解决此问题,您可以使用:

$hControl = ControlGetHandle($hExport, "", "[CLASS:ComboBox; INSTANCE:1]") ; get control handle
_GUICtrlComboBox_SetCurSel($hControl, 2) ; select something
$iID = _WinAPI_GetDlgCtrlID($hControl) ; get control ID
$wParam = BitOR($iID, BitShift($CBN_SELCHANGE, -16)) ; put ID and message together

_SendMessage($hExport, $WM_COMMAND, $wParam, $hControl) ; send massage