Zola123 Posted February 11, 2010 Share Posted February 11, 2010 Part of a script that I tried to write involved selecting an item in a combo box of another application. The app would then display other combo boxes depending on what was selected. I have tried using the combo box SelectString and SetCurSel functions to set the value in the combo box. The combo box is set correctly, however, the app doesn't display any other combo boxes when I use this function. If I just click and select using the mouse, everything works. Is there any way I can set a combo box selection as if the user clicked and selected it himself? For example GuiListView, GuiTreeView, GuiListBox, all possess a ClickItem function that works nicely. This function doesn't seem to exist for GuiComboBox. Thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 11, 2010 Share Posted February 11, 2010 You need to add a _SendMessage() to send the appropriate CBN_SELCHANGE notification. From MSDN: CBN_SELCHANGE Notification: Remarks To get the index of the current selection, send the CB_GETCURSEL message to the control. The CBN_SELCHANGE notification message is not sent when the current selection is set using the CB_SETCURSEL message. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Zola123 Posted February 19, 2010 Author Share Posted February 19, 2010 You need to add a _SendMessage() to send the appropriate CBN_SELCHANGE notification. From MSDN: CBN_SELCHANGE Notification: Thanks for that. The code that now works is as follows: WinWaitActive("My window", "") $hCntl = ControlGetHandle("My window", "", "[NAME:myCombo]") _GUICtrlComboBox_SetCurSel($hCntl, 5) $iCode = $CBN_SELCHANGE $val = BitShift($iCode, -16) $handle = WinGetHandle("My window", "") _SendMessage($handle, $WM_COMMAND, $val, $hCntl) It seems to work fine. Are there any improvements that could be made? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now