Lupo73 Posted April 10, 2011 Share Posted April 10, 2011 I found a couple of good solutions: (it shows the list of matching items dynamically, but it works only with the beginning of words and has a combo-size issue) (it works also with parts of words, but keeps the list always visible)I'd like to create something of similar, but the idea is a combobox shown in case a particular character is digit and that allows to add the selected text to the input (and not to replace it).Essentially, the user can digit in the input a path, but can also use environment variables in it. So for example he could digit a first part of the path and than if he digit % a list of env. var. is shown and he can choose to add one of them.Example:to obtain "C:\MyFolder\%FileAuthor%"the user could digit "C:\MyFolder\"than digit "%" and the list of environment variables is shownclicking the desired item in the combo, it is added in the input (but without removing the previous string)Maybe it is not possible to do, I don't know. Can anyone help me with it? Thanks! SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 10, 2011 Moderators Share Posted April 10, 2011 Lupo73, Flattery always helps! Try this: expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #Include <GuiComboBox.au3> #include <Array.au3> ; Clear flag $fAdded = False ; Read env vars and put into array Global Const $sRegKey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment" Global $aEnvVar[1][2] = [[0, 0]] $iCount = 0 While 1 $iCount += 1 $sKey = RegEnumVal($sRegKey, $iCount) If @error <> 0 Then ExitLoop $sValue = RegRead($sRegKey, $sKey) $aEnvVar[0][0] = $iCount ReDim $aEnvVar[$iCount + 1][2] $aEnvVar[$aEnvVar[0][0]][0] = $sKey $aEnvVar[$aEnvVar[0][0]][1] = $sValue WEnd _ArrayDisplay($aEnvVar) ; Create GUI $hGUI = GUICreate("Test", 500, 500) $hInput_1 = GUICtrlCreateInput("", 10, 10, 200, 20) $hInput_2 = GUICtrlCreateInput("", 260, 10, 200, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) $hCombo = GUICtrlCreateCombo("", 10, 40, 200, 20) GUICtrlSetState($hCombo, $GUI_HIDE) GUISetState() ; Fill combo $sComboList = "|" For $i = 1 To $aEnvVar[0][0] $sComboList &= $aEnvVar[$i][0] & "|" Next GUICtrlSetData($hCombo, $sComboList) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; Look for input $sInput = GUICtrlRead($hInput_1) ; If we see the first % If StringRight($sInput, 1) = "%" And $fAdded = False Then ; Show combo GUICtrlSetState($hCombo, $GUI_SHOW) _GUICtrlComboBox_ShowDropDown($hCombo, True) ; Wait until something is selected in the combo While 1 If GUICtrlRead($hCombo) <> "" And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then ; Hide the combo again GUICtrlSetState($hCombo, $GUI_HIDE) ; Option 1 = add %name% GUICtrlSetData($hInput_1, $sInput & GUICtrlRead($hCombo) & "%") ; Option 2 = add value $iIndex = _ArraySearch($aEnvVar, GUICtrlRead($hCombo)) GUICtrlSetData($hInput_2, StringTrimRight($sInput, 1) & $aEnvVar[$iIndex][1]) ; Reset the combo to remove value from edit GUICtrlSetData($hCombo, $sComboList) ; Set flag to prevent firing on final % of added env variable $fAdded = True ExitLoop EndIf WEnd ElseIf $sInput = "" Then ; Clear second input if first cleared GUICtrlSetData($hInput_2, "") ; Clear flag for new inputs $fAdded = False EndIf WEnd The second input is only there in case you wanted to add the value of the env variable rather than the name - just delete all reference to it if you do nto need it. Please ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Lupo73 Posted April 10, 2011 Author Share Posted April 10, 2011 Thanks for the help! It starts to be similar to the idea ..but I have few other questions: - is it possible to show only the list of the combo after the input and not the combo itself? (like the WideBoyDixon solution and in general like browsers) - is it possible to support more env. var. in the same string? (for example allow to write "C:\%FileAuthor%\%FileName%") SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 10, 2011 Moderators Share Posted April 10, 2011 Lupo73, show only the list of the combo after the input and not the combo itself support more env. var. in the same string?All you need to do is ask: expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #Include <GuiComboBox.au3> #include <Array.au3> ; Clear flag $fAdded = False ; Read env vars and put into array Global Const $sRegKey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment" Global $aEnvVar[1][2] = [[0, 0]] $iCount = 0 While 1 $iCount += 1 $sKey = RegEnumVal($sRegKey, $iCount) If @error <> 0 Then ExitLoop $sValue = RegRead($sRegKey, $sKey) $aEnvVar[0][0] = $iCount ReDim $aEnvVar[$iCount + 1][2] $aEnvVar[$aEnvVar[0][0]][0] = $sKey $aEnvVar[$aEnvVar[0][0]][1] = $sValue WEnd _ArrayDisplay($aEnvVar) ; Create GUI $hGUI = GUICreate("Test", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUISetState() ; Fill combo $sComboList = "|" For $i = 1 To $aEnvVar[0][0] $sComboList &= $aEnvVar[$i][0] & "|" Next GUICtrlSetData($hCombo, $sComboList) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; Look for input $sCombo = GUICtrlRead($hCombo) ; If we see the first % If StringRight($sCombo, 1) = "%" And $fAdded = False Then ; Show combo _GUICtrlComboBox_ShowDropDown($hCombo, True) ; Wait until something is selected in the combo While 1 If GUICtrlRead($hCombo) <> "" And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then ; Add %name% _GUICtrlComboBox_SetEditText ($hCombo, $sCombo & GUICtrlRead($hCombo) & "%") ; Set flag to prevent firing on final % of added env variable $fAdded = True ExitLoop EndIf WEnd ElseIf StringRight($sCombo, 1) <> "%" And $fAdded = True Then ; Clear flag for new inputs $fAdded = False EndIf WEnd Pretty good service for a Sunday afternoon I reckon! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Lupo73 Posted April 10, 2011 Author Share Posted April 10, 2011 It looks good, but a little issued sorry.. you are really helpful and I don't want to bore you.. Anyway, these are some issues: - sometimes when the list is shown, the mouse cursor is hidden - if no one item is selected from the list and is clicked out of it, in the input is added the previous string + %% (for example "Folder\%" becomes "Folder\%Folder\%%") - even if the user does not digit %, the combo-arrow allows to show the list of env. var. (essentially it looks like a combo box and not like an input field) I think a better solution could be obtained starting from WideBoyDixon (combo box seems to produce several problems), but I'm not able to modify it.. I think the result could be useful to other users, given that may be considered an advanced tool to auto-complete input fields SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 10, 2011 Moderators Share Posted April 10, 2011 Lupo73,I think a better solution could be obtained starting from WideBoyDixonThen I will leave you to it while I watch the Masters on TV! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Lupo73 Posted April 10, 2011 Author Share Posted April 10, 2011 You are right ..thanks for your time and for good functions you develop..I'll try to work on it and reply here for good news.. SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 11, 2011 Moderators Share Posted April 11, 2011 Lupo73, Try this version and see if it meets your requirements more closely: expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #Include <GuiComboBox.au3> #include <Misc.au3> #include <Array.au3> Opt("GUICloseOnESC", 0) ; Clear flag $fAdded = False $iCurrLen = 0 $dll = DllOpen("user32.dll") ; Read env vars and put into array Global Const $sRegKey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment" Global $aEnvVar[1][2] = [[0, 0]] $iCount = 0 While 1 $iCount += 1 $sKey = RegEnumVal($sRegKey, $iCount) If @error <> 0 Then ExitLoop $sValue = RegRead($sRegKey, $sKey) $aEnvVar[0][0] = $iCount ReDim $aEnvVar[$iCount + 1][2] $aEnvVar[$aEnvVar[0][0]][0] = $sKey $aEnvVar[$aEnvVar[0][0]][1] = $sValue WEnd ;_ArrayDisplay($aEnvVar) ; Create GUI $hGUI = GUICreate("Test", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetState(-1, $GUI_HIDE) $hInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUISetState() ; Fill combo $sComboList = "|" For $i = 1 To $aEnvVar[0][0] $sComboList &= $aEnvVar[$i][0] & "|" Next GUICtrlSetData($hCombo, $sComboList) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE On_Exit() EndSwitch ; Look for input $sInput = GUICtrlRead($hInput) ; If we see the first % If StringRight($sInput, 1) = "%" And StringLen($sInput) > $iCurrLen And $fAdded = False Then ; Show combo GUICtrlSetState($hCombo, $GUI_SHOW) _GUICtrlComboBox_ShowDropDown($hCombo, True) While 1 ; Wait until something is selected in the combo If GUICtrlRead($hCombo) <> "" And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then _GUICtrlComboBox_ShowDropDown($hCombo, False) GUICtrlSetState($hCombo, $GUI_HIDE) ; Add %name% GUICtrlSetData($hInput, $sInput & GUICtrlRead($hCombo) & "%") GUICtrlSetState($hInput, $GUI_FOCUS) ControlSend($hGUI, "", $hInput, "{END}") ; reset combo GUICtrlSetData($hCombo, $sComboList) ; Set flag to prevent firing on final % of added env variable $fAdded = True ; Set length to prevent firing on backspace $iCurrLen = StringLen(GUICtrlRead($hInput)) ExitLoop EndIf ; Or until Esc pressed which prevents a selection If _IsPressed("1B", $dll) Then GUICtrlSetData($hInput, StringTrimRight($sInput, 1)) GUICtrlSetState($hInput, $GUI_FOCUS) ControlSend($hGUI, "", $hInput, "{END}") _GUICtrlComboBox_ShowDropDown($hCombo, False) GUICtrlSetState($hCombo, $GUI_HIDE) ExitLoop EndIf If GUIGetMsg() = $GUI_EVENT_CLOSE Then On_Exit() EndIf WEnd ElseIf StringRight($sInput, 1) <> "%" Then ; Clear flag for new inputs If $fAdded = True Then $fAdded = False ; Set new count $iCurrLen = StringLen(GUICtrlRead($hInput)) EndIf WEnd Func On_Exit() DllClose($dll) Exit EndFunc M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Lupo73 Posted April 11, 2011 Author Share Posted April 11, 2011 Wow! Great! Thanks for the help.. SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 11, 2011 Moderators Share Posted April 11, 2011 Lupo73,Wow! Great!I take it from that that the script does what you wanted! Glad I could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
guinness Posted April 13, 2011 Share Posted April 13, 2011 Nice example Melba23 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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