everseeker Posted April 24, 2008 Share Posted April 24, 2008 (edited) Have 2 combo boxes on a form When a selection is made in the first one, the contents of the second one are filled The change is triggered by OnIndexChange I am working with the first with this code ControlFocus("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]") ComboBox_SelectString("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]", "PORTRAIT Share 80 Plus Rx Unlimited") sleep(2000) ComboBox_SelectString("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]", "MONOGRAM Total Plus Rx") sleep(2000) ComboBox_SelectString("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]", $MasterArray[$Counter][34]) Sleep(2000) ConsoleWrite("Plan Chosen: " & $MasterArray[$Counter][34] & @CRLF)oÝ÷ ÚØ^~*ì·kç-±ªÞvÞ¶äDBÈZ§Ø^ríz{l¶Âä±8^«-Ëay§-¹©i©ìzW¶*'Ü(®K-¢TNz'zíç!jx²+-®( z¸§Ø^±ç(×(º£h~)erëyËeÈèaz··öËax*&nhÅ'¥yËR¶¸§û§rب«¢+ÙÕ¹ ½µ½ ½á}M±ÑMÑÉ¥¹ ÀÌØíÝ¥¹Q¥Ñ±°ÀÌØíÝ¥¹QáаÀÌØí½¹Ñɽ°°ÀÌØí½ÁÑ¥½¸¤(1½°ÀÌØí¡]¹ô ½¹Ñɽ±Ñ!¹± ÀÌØíÝ¥¹Q¥Ñ±°ÀÌØíÝ¥¹QáаÀÌØí½¹Ñɽ°¤(1½°ÀÌØí¥¹àô}U% Ñɱ ½µ½ ½á}¥¹MÑÉ¥¹ ÀÌØí¡]¹°ÀÌØí½ÁÑ¥½¸¤(%ÀÌØí¥¹àô´ÄQ¡¸(MÑÉÉ½È Ä¤(IÑÕɸ±Í(¹%((%ÀÌØí¥¹àôÀQ¡¸(ì%Ñ¡¥Ñ´¥ÌÑ¡¥ÉÍÐ¥¸Ñ¡±¥ÍаÕÍ¡½ÑåÌѼ¹Ù¥ÑѼ¥Ð( ½¹Ñɽ±M¹ ÀÌØíÝ¥¹Q¥Ñ±°ÀÌØíÝ¥¹QáаÀÌØí¡]¹°ÅÕ½ÐííAUAôÅÕ½Ðì¤(±Í(ìM±ÐÑ¡¥Ñ´É¥¡Ð½ÉÑ¡ÑÉÐ¥¹à°Ñ¡¸Í¹½Ý¸(}U% Ñɱ ½µ½ ½á}MÑ ÕÉM° ÀÌØí¡]¹°ÀÌØí¥¹à´Ä¤( ½¹Ñɽ±M¹ ÀÌØíÝ¥¹Q¥Ñ±°ÀÌØíÝ¥¹QáаÀÌØí¡]¹°ÅÕ½Ðíí=]9ôÅÕ½Ðì¤(¹%(IÑÕɸQÉÕ)¹Õ¹ìôôÐí ½µ½ ½á}M±ÑMÑÉ¥¹ Any thoughts on how to get this to fire the event? Edited April 27, 2008 by everseeker Everseeker Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 24, 2008 Moderators Share Posted April 24, 2008 When you say:BUTnone of the changes is triggering the second combo box to fill correctly....Do you mean they are not filled at all, or they are filled in the wrong index position? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
everseeker Posted April 24, 2008 Author Share Posted April 24, 2008 (edited) When you say: Do you mean they are not filled at all, or they are filled in the wrong index position? here's 2 videos, 1 manual, 1 showing what Autoit is doing... (changed the code slightly... what I am doing now: (tried multiple set-focus's) ) Sleep(4000) ControlFocus("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]") ComboBox_SelectString("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]", "PORTRAIT Share 80 Plus Rx Unlimited") ControlFocus("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a13]") Sleep(2000) ControlFocus("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]") ComboBox_SelectString("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]", "MONOGRAM Total Plus Rx") ControlFocus("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a13]") Sleep(2000) ControlFocus("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]") ComboBox_SelectString("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]", $MasterArray[$Counter][34]) ControlFocus("Rate Calculator", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a13]") Sleep(2000) ConsoleWrite("Plan Chosen: " & $MasterArray[$Counter][34] & @CRLF) If you look at the manual one, you can see that, as I change the value in the top box, the choices in the bottom one change (other parts of the page change too... you can see bits of that) In the autoit one, you will note that NOTHING changes but the field getting managed... THis is a problem because, for some cases, I need to "pick" a value in box #2 that is ...not there... thus causing malnourisment and discontent Edited April 24, 2008 by everseeker Everseeker Link to comment Share on other sites More sharing options...
zorphnog Posted April 24, 2008 Share Posted April 24, 2008 Seems to be a problem with triggering the change event. Maybe you should move the focus to some other control before you move it to the second combo. Link to comment Share on other sites More sharing options...
everseeker Posted April 24, 2008 Author Share Posted April 24, 2008 Seems to be a problem with triggering the change event. Maybe you should move the focus to some other control before you move it to the second combo.OK.... Just tried it................................................................... ............................................................................................. No effect Everseeker Link to comment Share on other sites More sharing options...
zorphnog Posted April 24, 2008 Share Posted April 24, 2008 (edited) Maybe... Func ComboBox_SelectString($winTitle, $winText, $control, $option) Local $hWnd = ControlGetHandle($winTitle, $winText, $control) Local $index = _GUICtrlComboBox_FindString($hWnd, $option) If $index = -1 Then SetError(1) Return False EndIf _GUICtrlComboBox_ShowDropDown($hWnd, True) _GUICtrlComboBox_SetCurSel($hWnd, $index) _GUICtrlComboBox_ShowDropDown($hWnd) Return True EndFunc ;==>ComboBox_SelectString Edited April 24, 2008 by zorphnog Link to comment Share on other sites More sharing options...
Siao Posted April 24, 2008 Share Posted April 24, 2008 Are you sure the second combo change is triggered ok when doing it manually with keyboard (exactly the same steps you do in script) too? "be smart, drink your wine" Link to comment Share on other sites More sharing options...
everseeker Posted April 24, 2008 Author Share Posted April 24, 2008 Are you sure the second combo change is triggered ok when doing it manually with keyboard (exactly the same steps you do in script) too?Quite sure(I added a couple steps in the video to demonstrate that the contents of the second dropdown were changing) Everseeker Link to comment Share on other sites More sharing options...
everseeker Posted April 24, 2008 Author Share Posted April 24, 2008 Maybe... Func ComboBox_SelectString($winTitle, $winText, $control, $option) Local $hWnd = ControlGetHandle($winTitle, $winText, $control) Local $index = _GUICtrlComboBox_FindString($hWnd, $option) If $index = -1 Then SetError(1) Return False EndIf _GUICtrlComboBox_ShowDropDown($hWnd, True) _GUICtrlComboBox_SetCurSel($hWnd, $index) _GUICtrlComboBox_ShowDropDown($hWnd) Return True EndFunc ;==>ComboBox_SelectString that method does not actually DO anything in a .Net environment... the selection is highlighted, but not "made" (Box opens, selection is highlighted, box closes, default is still selected.. odd thing with the setcursel... that's all it does, set the cursor to the selection...) Everseeker Link to comment Share on other sites More sharing options...
everseeker Posted April 24, 2008 Author Share Posted April 24, 2008 (edited) Looked at your code and ...extended the thought a bit.... BINGO BINGO BINGO!!!!! Here's the combination of our 2 functions..... Func ComboBox_SelectString($winTitle, $winText, $control, $option) Local $hWnd = ControlGetHandle($winTitle, $winText, $control) Local $index = _GUICtrlComboBox_FindString($hWnd, $option) If $index = -1 Then SetError(1) Return False EndIf ;_GUICtrlComboBox_ShowDropDown($hWnd, True) ;_GUICtrlComboBox_SetCurSel($hWnd, $index) ;_GUICtrlComboBox_ShowDropDown($hWnd) If $index = 0 Then ; If the item is the first in the list, use hotkeys to navigate to it _GUICtrlComboBox_ShowDropDown($hWnd, True) ControlSend($winTitle, $winText, $hWnd, "{PGUP}") _GUICtrlComboBox_ShowDropDown($hWnd) Else ; Select the item right before the target index, then send down _GUICtrlComboBox_ShowDropDown($hWnd, True) _GUICtrlComboBox_SetCurSel($hWnd, $index - 1) ControlSend($winTitle, $winText, $hWnd, "{DOWN}") _GUICtrlComboBox_ShowDropDown($hWnd) EndIf Return True EndFunc ;==>ComboBox_SelectString Works like a champ. Guess the event would not "trigger" till the control was toggled open and shut...... Good to know! Edited April 24, 2008 by everseeker Everseeker Link to comment Share on other sites More sharing options...
everseeker Posted April 24, 2008 Author Share Posted April 24, 2008 Maybe... Func ComboBox_SelectString($winTitle, $winText, $control, $option) Local $hWnd = ControlGetHandle($winTitle, $winText, $control) Local $index = _GUICtrlComboBox_FindString($hWnd, $option) If $index = -1 Then SetError(1) Return False EndIf _GUICtrlComboBox_ShowDropDown($hWnd, True) _GUICtrlComboBox_SetCurSel($hWnd, $index) _GUICtrlComboBox_ShowDropDown($hWnd) Return True EndFunc ;==>ComboBox_SelectString Thanks! Everseeker Link to comment Share on other sites More sharing options...
zorphnog Posted April 24, 2008 Share Posted April 24, 2008 No problem. 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