Sign in to follow this  
Followers 0
Zola123

Combo box click item

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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.

:mellow:


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

Share this post


Link to post
Share on other sites

You need to add a _SendMessage() to send the appropriate CBN_SELCHANGE notification. From MSDN: CBN_SELCHANGE Notification:

:mellow:

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?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0