rossati Posted January 28, 2016 Share Posted January 28, 2016 Hello I have a little problem with combo box i.e. I need to capture the choice only when a mouse or enter key are pressed. Therefore the choice is fired even when the list is traversed by the navigation arrows. There is the possibility to test if the choice is per keybord enter or mouse click? Thanks Link to comment Share on other sites More sharing options...
AutoBert Posted January 28, 2016 Share Posted January 28, 2016 Add a Button with style $BS_DEFPUSHBUTTON to your Gui. And listen the Event he fired (Click or Enter). Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 28, 2016 Moderators Share Posted January 28, 2016 @rossati you limit the help we can offer when you don't bother posting any code. I am guessing you mean something like this? If I am incorrect, please post code showing what you're trying to do. ;=================Select the Day from the Combo Box with the Enter key=========================== #include<MsgBoxConstants.au3> #include <GUIConstantsEx.au3> $LoginForm = GUICreate("Test My Combo Box", 300, 100) $cmbBox = GUICtrlCreateCombo("", 60, 44, 125, 21) GUICtrlSetData($cmbBox,'Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday') $myDummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{ENTER}", $myDummy]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $myDummy MsgBox($MB_OK, "Test My Combo Box", "You Selected " & GUICtrlRead($cmbBox)) EndSwitch WEnd DavidLago 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
rossati Posted January 29, 2016 Author Share Posted January 29, 2016 Hello Thanks to all. JLogan3o13 your script introduced me some useful features, however does not solve my problem: I have a great combo (the styles of a word document); from this combo I have to choose one or more styles that is, each chosen from the combo is queued in a text field. Unfortunately surfing the combo with arrows generates a choice and I don't think there's no way to differentiate DOWN, UP from ENTER (or click). John Rossati Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 29, 2016 Moderators Share Posted January 29, 2016 @rossati as I mentioned above, probably the best thing you can do to ensure we see exactly what you're trying to do, is to post your code (even if it isn't working the way you want it to). Otherwise, as I seemed to have been above, we're first having to guess at what your intent is and then try and troubleshoot. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
rossati Posted January 30, 2016 Author Share Posted January 30, 2016 Thanks Here a fragment rebuild from a complex form obtained by my form generator. ;================= Try Select Normale and Script =========================== #include <GUIConstantsEx.au3> $frm = GUICreate("Test big Combo Box", 260, 180) $cmbBox = GUICtrlCreateList("", 60, 40, 125, 21) GUICtrlSetData($cmbBox,'Acronimo HTML|Citazione|Contenuto cornice|Contenuto elenco|Contenuto tabella|Didascalia|Figure|Firma|Indirizzo destinatario' _ & '|Indirizzo HTML|Indirizzo mittente|Intestazione|Intestazione messaggio|Intestazione nota|Normale|Normale (Web)|Numero elenco|' _ & '|Numero elenco 2|Numero elenco 3|Numero elenco 4|Numero elenco 5|Numero pagina|Numero riga|OOoEmphasis|OOoMenuPath|OOoStrongEmphasis' _ & '|OOoTableText|Paragrafo elenco|Preformattato HTML|Primo rientro corpo del testo|Punti|Punto elenco|Rientro corpo del testo' _ & '|Rientro normale|Riferimento delicato|Riferimento intenso|Rimando commento|Rimando nota di chiusura|Salto a indice|Script' _ & '|Sfondo a colori||Soggetto commento|Sommario 1|Sottotitolo|Tabella|Tastiera HTML|Testo|Testo commento|Testo del blocco|Testo fumetto' _ & '|Testo macro|Testo non proporzionale|Testo normale|Testo nota di chiusura|Testo preformattato|Testo segnaposto|Testo sorgente|Titolo|Variabile') $txt = GUICtrlCreateInput("", 60, 64, 125, 21) $cmbFonts = GUICtrlCreateCombo("", 60, 90, 125, 21) GUICtrlSetData($cmbFonts,'Arial|Courier New|Times New Roman|Verdana') $idBTN = GUICtrlCreateButton("Close", 85, 145, 80, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE,$idBTN MsgBox(0,"",GUICtrlRead($txt)) ExitLoop Case $cmbBox GUICtrlSetData($txt, GUICtrlRead($txt) & "," & GUICtrlRead($cmbBox)) EndSwitch WEnd Some words of explication: I need to select one or some styles which are inserted on a text. It is perfectly possible to choose only what I want as long as I don't use arrows that practically function as the enter key or mouse click I think there is no solution with standard library. John Rossati Link to comment Share on other sites More sharing options...
AutoBert Posted January 30, 2016 Share Posted January 30, 2016 (edited) please correct your title JLogan3o13 answered at problem with GuiCtrlCreateCombo. I also thout you are using this control. But where is your problem toimplement my advice in your code: ; *** Start added by AutoIt3Wrapper *** #include <ButtonConstants.au3> ; *** End added by AutoIt3Wrapper *** #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;================= Try Select Normale and Script =========================== #include <GUIConstantsEx.au3> $frm = GUICreate("Test big Combo Box", 260, 180) $cmbBox = GUICtrlCreateList("", 60, 10, 125, 21) GUICtrlSetData($cmbBox,'Acronimo HTML|Citazione|Contenuto cornice|Contenuto elenco|Contenuto tabella|Didascalia|Figure|Firma|Indirizzo destinatario' _ & '|Indirizzo HTML|Indirizzo mittente|Intestazione|Intestazione messaggio|Intestazione nota|Normale|Normale (Web)|Numero elenco|' _ & '|Numero elenco 2|Numero elenco 3|Numero elenco 4|Numero elenco 5|Numero pagina|Numero riga|OOoEmphasis|OOoMenuPath|OOoStrongEmphasis' _ & '|OOoTableText|Paragrafo elenco|Preformattato HTML|Primo rientro corpo del testo|Punti|Punto elenco|Rientro corpo del testo' _ & '|Rientro normale|Riferimento delicato|Riferimento intenso|Rimando commento|Rimando nota di chiusura|Salto a indice|Script' _ & '|Sfondo a colori||Soggetto commento|Sommario 1|Sottotitolo|Tabella|Tastiera HTML|Testo|Testo commento|Testo del blocco|Testo fumetto' _ & '|Testo macro|Testo non proporzionale|Testo normale|Testo nota di chiusura|Testo preformattato|Testo segnaposto|Testo sorgente|Titolo|Variabile') $idEnterButon = GUICtrlCreateButton('&OK',190,10,40,21,$BS_DEFPUSHBUTTON) $txt = GUICtrlCreateInput("", 60, 64, 125, 21) $cmbFonts = GUICtrlCreateCombo("", 60, 90, 125, 21) GUICtrlSetData($cmbFonts,'Arial|Courier New|Times New Roman|Verdana') $idBTN = GUICtrlCreateButton("Close", 85, 145, 80, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE,$idBTN MsgBox(0,"",GUICtrlRead($txt)) ExitLoop Case $idEnterButon GUICtrlSetData($txt, GUICtrlRead($txt) & "," & GUICtrlRead($cmbBox)) EndSwitch WEnd JLogan3o13 way to solve is the same easy way to adapt in your script. But for user comfort using _GUICtrlListBox_Create is the better solution. This allows user to make multiple selections. So: about _GUICtrlListBox_GetSelItemsText and test its example. Edited January 30, 2016 by AutoBert Link to comment Share on other sites More sharing options...
rossati Posted February 4, 2016 Author Share Posted February 4, 2016 Thanks AutoBert, your suggestion is a good compromise. John Rossati 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