BlackDawn187 Posted February 21, 2014 Share Posted February 21, 2014 Hey guys, I'm currently in the midst of adding a Intellisense feature to one of my GUI Inputs. Unfortunately it seems, That all the current searchable udfs/examples. Are either a mess or, too large to consider including. I've ran out of free time today and, I'm hoping someone with a little more experience with the matter could polish some things off for me in the code attached below. But, Before you consider helping out, Let me brief you on what it needs to do. Like any intellisense, It has to display previous inputs as suggestions, Which are logged in the rest of the script. It needs to also auto-complete and, While I would like it to automatically submit the input. I can handle that as I'm using _IsPressed("0D"). Anyways without further ado, This is what I've come up with so far given the existing structure of my script; $InputData_2 = GUICtrlRead($Input1, "") If $InputData_2 > "" And FileExists("" & @TempDir & "\History.dat") Then ; History.dat is where previous submissions are stored While 2 If _IsPressed("0D", $hDLL) And WinActive("" & $Title & " v" & $Version & " by " & $Author & "", "") Then ; Checks for Enter ExitLoop Else $CombinedData = GUICtrlRead($Input1, "") If $CombinedData = $InputData_2 Then ; Make sure the Input hasn't changed since the While loop was started $History = "" If Not _FileReadToArray("" & @TempDir & "\History.dat", $History) Then ; Read previously stored/submitted Inputs Sleep("100") EndIf For $i = 1 To $History[0] ;MsgBox(0, 'History: ' & $i, $History[$i]) ;Debug $HistoryData = StringInStr($History[$i], $InputData_2) ; Check if the current text(""substring"") is found in the previously stored/submitted Input file If $HistoryData <> "0" Then ; If the text is found then display the gui below $LB_GUI_Height = Number(30 * $i) $LB_GUI = GUICreate("", 600, $LB_GUI_Height, 0, 350, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_MDICHILD), $Form1) ; $Form1 is the Main GUI where the Input Control is located $LB = GUICtrlCreateList("", 0, 0, 600, $LB_GUI_Height, BitOR(0x00100000, 0x00200000)) GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif") GUICtrlSetData($LB, $History[$i]) ; Show previously stored/submitted Inputs in a Listbox GUISetState(@SW_SHOW, $LB_GUI) EndIf Next ElseIf $InputData_2 <> $CombinedData Then ; If Input has changed destroy the existing gui from above GUIDelete($LB_GUI) ExitLoop EndIf EndIf WEnd Anything you guys can point out would be helpful as I have to leave this until tomorrow or later.. Thanks for any contributions. Link to comment Share on other sites More sharing options...
FireFox Posted February 21, 2014 Share Posted February 21, 2014 Hi, Have you tried the _GUICtrlComboBox_AutoComplete function? Br, FireFox. Link to comment Share on other sites More sharing options...
FireFox Posted February 21, 2014 Share Posted February 21, 2014 As your request is not an easy thing to do, this is the smaller you can do : expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ListViewConstants.au3> #include <GUIListBox.au3> #include <Misc.au3> Local $_sHistory = FileRead("history.txt") Local $_sList = FileRead("list.txt") #Region GUI GUICreate("MyGUI") Global $_iInput1 = GUICtrlCreateInput("", 10, 10, 200, 22) $_iListHistory = GUICtrlCreateList("", 10, 50, 100, 100) GUICtrlSetData($_iListHistory, StringReplace($_sHistory, @CRLF, "|")) $_iListResults = GUICtrlCreateList("", 110, 50, 100, 100) $_hListResults = GUICtrlGetHandle($_iListResults) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) #EndRegion GUI While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd GUIDelete() Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iCtrlID = BitAND($wParam, 0x0000FFFF) Local $iCode = BitShift($wParam, 16) Local Static $fMyInputHasFocus = False Switch $iCtrlID Case $_iInput1 Switch $iCode Case $EN_CHANGE _Intellisense() Case $EN_SETFOCUS $fMyInputHasFocus = True Case $EN_KILLFOCUS $fMyInputHasFocus = False EndSwitch Case $_iListHistory Switch $iCode Case $LVNI_FOCUSED GUICtrlSetData($_iInput1, GUICtrlRead($_iListHistory)) _Intellisense() EndSwitch Case 1 If $fMyInputHasFocus And _IsPressed("0D") Then Local $s = GUICtrlRead($_iInput1) $_sHistory &= $s & @CRLF FileWriteLine("history.txt", $s) _GUICtrlListBox_AddString(GUICtrlGetHandle($_iListHistory), $s) EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Intellisense() _GUICtrlListBox_BeginUpdate($_hListResults) _GUICtrlListBox_ResetContent($_hListResults) Local $s = GUICtrlRead($_iInput1) If $s <> "" Then $a = StringRegExp($_sHistory, "(?m)^.*\Q" & $s & "\E.*$", 3) If IsArray($a) = 1 Then For $i = 0 To UBound($a) - 1 _GUICtrlListBox_AddString($_hListResults, $a[$i]) Next EndIf EndIf _GUICtrlListBox_EndUpdate($_hListResults) EndFunc ;==>_Intellisense In the leftbox the history and in the rightbox the results Press ENTER to save the input in the history If you want to make it user friendly it will require some few lines Br, FireFox. Fubarable 1 Link to comment Share on other sites More sharing options...
BlackDawn187 Posted February 22, 2014 Author Share Posted February 22, 2014 Thanks Firefox for both of your examples, As I'm a little unfamiliar with the Combo Boxes, I think it would be a little outside of my current knowledge as to how to incorporate it with what I currently have. Although, I did test it and, Look through the code. The second example on the other hand, I can make more sense of and, I think I could better include that into my script than the previous example. Something I also hadn't considered was reading the specific include file EditConstants, Which upon viewing your example and the include file I'm almost certain I can improve upon my script. Thanks for peeling back the wool infront of my eyes Link to comment Share on other sites More sharing options...
BlackDawn187 Posted February 22, 2014 Author Share Posted February 22, 2014 (edited) Hey @FireFox, I was wondering if you could offer some insight on a issue that I'm having. I'm pretty sure it has to do with GUIGetMsg, I'm not very experienced with dealing with WM_COMMAND. I've attached two photos below which show the current structure of my code, I just don't know how to do the BitShift/BitAnd using what I have. Right now I'm just working on getting $EN_CHANGE, I have $EN_SETFOCUS written to create the Intellisense GUI(If Applicable). Then when $EN_CHANGE is received (As anything other than Enter) it populates the Intellisense GUI with the previously stored/submitted commands. I guess all what I'm asking is how would I go about receiving the $EN_CHANGE constants according to what I have below? Should I just remove the Switch inside $Input1 and, Put it in it's own function? At the time this all sounds comprehend-able, But if I've left something out or confused you at all. I'll correct it as soon as I'm available again. Once again your assistance in this matter is greatly appreciated! Top View: Expanded View: Edited February 22, 2014 by BlackDawn187 Link to comment Share on other sites More sharing options...
FireFox Posted February 22, 2014 Share Posted February 22, 2014 You're doing it wrong. Those messages are sent to the function you've provided in the GUIRegisterMsg function, typically the function name is the name of the constant for the message you've registered. So take a look at my script, just copy paste my WM_COMMAND with the GUIRegisterMsg function and edit it to your needs. Br, FireFox. Link to comment Share on other sites More sharing options...
MyEarth Posted September 22, 2014 Share Posted September 22, 2014 Sorry if i bump the thread, but if instead of a TXT file in this part: Local $_sHistory = FileRead("history.txt") I want to use an array: Local $_sHistory[2] = ["Autoit", "Cool"] What is the changes to do at Intellisense()? Thanks 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