Efo74 Posted January 13, 2021 Share Posted January 13, 2021 Hello Autoit People , I don't know if it is possible to solve this problem with a combobox control. In the example I entered, I made a combobox with the following elements AItem 1 | BItem 2 | CItem 3 | DItem 4. During use, the user can expand the control and ... by pressing for example the letter C, it will automatically move to the CItem 3 line ... pressing B to the BItem 2 line and so on. I would like to know if it is possible to change this behavior and allow to press for example 2 to go to the BItem 2 line ... press 4 to go to the DItem4 line. I would like to be able to choose which font to start with for the quick search. In this case, instead of starting from the first character, I would like it to start from character 7. Is it possible somehow ?? Thanks for the support. code: expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiComboBox.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 300, 200) ; Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("AItem 1", 10, 10, 185, 20,$CBS_DROPDOWNLIST+$WS_VSCROLL) Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Add additional items to the combobox. GUICtrlSetData($idComboBox, "BItem 2|CItem 3|DItem 4", "EItem 2") ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Local $sComboRead = "" ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idComboBox $sComboRead = GUICtrlRead($idComboBox) MsgBox($MB_SYSTEMMODAL, "", "The combobox is currently displaying: " & $sComboRead, 0, $hGUI) EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example :rolleyes: Link to comment Share on other sites More sharing options...
seadoggie01 Posted January 14, 2021 Share Posted January 14, 2021 It's probably possible other ways, but the simplest would seem to be to re-name your items to look like "1 - AItem 1". Then, when you need the value, remove the first 4 characters with StringTrimLeft($sValue, 4) If that doesn't work for you, you could look into using GUISetAccelerators, though that would activate the ComboBox item regardless of where you select on the GUI All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
Nine Posted January 14, 2021 Share Posted January 14, 2021 Here a way you could do it : expandcollapse popup#include <GUIConstants.au3> #include <GuiComboBox.au3> #include <Constants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 300, 200) ; Create a combobox control. Global $idComboBox = GUICtrlCreateCombo("AItem 1", 10, 10, 185, 20) Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Add additional items to the combobox. GUICtrlSetData($idComboBox, "BItem 2|CItem 3|DItem 4", "EItem 2") GUISetState() GUIRegisterMsg($WM_COMMAND, WM_COMMAND) Local $sComboRead = "" ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idComboBox $sComboRead = GUICtrlRead($idComboBox) MsgBox($MB_SYSTEMMODAL, "", "The combobox is currently displaying: " & $sComboRead, 0, $hGUI) EndSwitch WEnd EndFunc ;==>Example Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $iIDFrom = _WinAPI_LoWord($iwParam), $iCode = _WinAPI_HiWord($iwParam) Local $sText, $sInd If $iIDFrom = $idComboBox Then If $iCode = $CBN_EDITCHANGE Then $sInd = _GUICtrlComboBox_GetEditText($idComboBox) For $i = 0 To _GUICtrlComboBox_GetCount($idComboBox) - 1 _GUICtrlComboBox_GetLBText($idComboBox, $i, $sText) If StringInStr($sText, $sInd) Then _GUICtrlComboBox_SetCurSel($idComboBox, $i) ExitLoop EndIf Next EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND seadoggie01 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Efo74 Posted January 14, 2021 Author Share Posted January 14, 2021 Thank you very much you are my savior, just what I was looking for. Now I have to study your code to adapt it to my needs. Thanks again. :rolleyes: Link to comment Share on other sites More sharing options...
Nine Posted January 14, 2021 Share Posted January 14, 2021 Glad you like it “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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