Kovacic Posted January 13, 2014 Posted January 13, 2014 I am taking some idea from here: '?do=embed' frameborder='0' data-embedContent>> But what I am looking to accomplish is simple, I want to have an input box with a hidden input box below it. I will also have a defined list of items. When the text box has any value in it that does not directly equal an item in the pre defined list, the edit box should show. and populate suggested items based on whats being typed which I will do that part later, should be easy. I am stuck on a simple portion which should be easy and i'm not sure why I am having trouble with it. The way thr code below should work is, as long as there is a value in the Input box, the edit box will appear, if there is no value in the input box, the edit box should be hidden. here is what I have so far: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) $Input1 = GUICtrlCreateInput("", 64, 72, 313, 21) $Edit1 = GUICtrlCreateEdit("", 64, 96, 313, 177) GUISetState(@SW_SHOW) GUICtrlSetState($Edit1, $GUI_HIDE) While 1 $words = GUICtrlRead($Input1) If $words NOT = "" then GUICtrlSetState($Edit1, $GUI_SHOW) else GUICtrlSetState($Edit1, $GUI_HIDE) endif $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd func flopdrop() If BitAnd($Edit1,2) AND $words = "" Then GUICtrlSetState($Edit1, $GUI_HIDE) Else GUICtrlSetState($Edit1, $GUI_SHOW) EndIf endfunc the problem with this is a nasty flicker when you move the mouse or do anything else. I will get rid of the scroll bars too, but thats once I solve this flicker issue. I know its happening because I have the check being performed within the While statement, but I can't think of any other way to do it.. I even tried using a timer to only check once every few seconds, but that didn't seem to work either: If $words NOT = "" AND (@SEC = 00 OR 10 OR 20 OR 30 OR 40 OR 50) AND (@MSEC < 20)) Then ; Blah blah blah endIf Does anyone have any thoughts or has anyone been able to do this? Thanks in advance!! C0d3 is P0etry( ͡° ͜ʖ ͡°)
JohnOne Posted January 13, 2014 Posted January 13, 2014 You could start with >this script from martin. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Rogue5099 Posted January 13, 2014 Posted January 13, 2014 Its flickering due to GuiCtrlSetState constantly. Best option would be to get the state and if its already shown then skip showing it. My projects: Inventory / Mp3 Inventory, Computer Stats
Kovacic Posted January 13, 2014 Author Posted January 13, 2014 You could start with >this script from martin. I actually did try that one, but it doesn't do what I am looking for... I was hoping for a drop down you could click on if you see the object you want. Its flickering due to GuiCtrlSetState constantly. Best option would be to get the state and if its already shown then skip showing it. I did have that in an If statement, but it was still flickering. C0d3 is P0etry( ͡° ͜ʖ ͡°)
JohnOne Posted January 13, 2014 Posted January 13, 2014 Tried using a combo box? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Kovacic Posted January 13, 2014 Author Posted January 13, 2014 Im going to try combining martins script with mine, I like the idea of just using a label, because it can be easily clicked on to finish the auto complete... If it works, I'll post the final code for others to use and give Martin credit. C0d3 is P0etry( ͡° ͜ʖ ͡°)
Kovacic Posted January 13, 2014 Author Posted January 13, 2014 I am so close I can taste it!! I now have a list box pop up under the input box with some search options, I just want to make it so if you click on the option you want, it populates... OR maybe be able to press the down arrow until you find the option you want.. I think a few people in the past were asking for something like this so it might be a good find if we can make it work.. Here is the latest and greatest (it normally pulls from SQL, but I put in a mock line to emulate results of random words): expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #cs $conn = ObjCreate( "ADODB.Connection" ) $DSN = "All my SQL connection stuff" $conn.Open($DSN) $rs = ObjCreate("ADODB.RecordSet") $rs.Open("SELECT Serial FROM tbl_Manual", $conn) ;$rs.Open("SELECT TOP 20 Serial FROM tbl_Manual", $conn) If $RS.RecordCount Then While Not $RS.EOF local $MyVal = $MyVal & "|" & StringStripWS($rs.Fields("serial").value,8) $RS.MoveNext WEnd EndIf $RS.Close $conn.close #ce $MyVal = "fracturing|enzygotic|bondwoman|mealtime|miketime|kimball|kiteball|unreelable|aruspices|prevoted|punt|taxis" local $MyVal2 = $MyVal $MyVal = StringSplit($MyVal,"|") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") $gui = GUICreate("My GUI edit") $IP = GUICtrlCreateInput("", 10, 18, 200, 22) $Edit1 = GUICtrlCreateList("", 10, 40, 200, 177) GUICtrlSetState($Edit1, $GUI_Hide) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func WM_COMMAND($hWnd, $msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) If $nID = $IP Then $hCtrl = $lParam If $nNotifyCode = $EN_CHANGE Then $txt = GUICtrlRead($IP) For $n = 1 To UBound($MyVal) - 1 If StringCompare(StringLeft($MyVal[$n], StringLen($txt)), $txt) = 0 Then GUICtrlSetData($Edit1, $MyVal[$n]) if GUICtrlRead($IP) then GUICtrlSetState($Edit1, $GUI_show) else GUICtrlSetState($Edit1, $GUI_Hide) endif ExitLoop EndIf Next EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND As usual, any and all comments, hints, tips, spelling corrections, suggestions are welcome! C0d3 is P0etry( ͡° ͜ʖ ͡°)
JohnOne Posted January 13, 2014 Posted January 13, 2014 I think this piece of code in callback function determines that the message came from input, If $nID = $IP Then $hCtrl = $lParam If $nNotifyCode = $EN_CHANGE Then $txt = GUICtrlRead($IP) For $n = 1 To UBound($MyVal) - 1 If StringCompare(StringLeft($MyVal[$n], StringLen($txt)), $txt) = 0 Then GUICtrlSetData($Edit1, $MyVal[$n]) if GUICtrlRead($IP) then GUICtrlSetState($Edit1, $GUI_show) else GUICtrlSetState($Edit1, $GUI_Hide) endif ExitLoop EndIf Next EndIf EndIf you might have to code another condition for your list box. Kovacic 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Kovacic Posted January 14, 2014 Author Posted January 14, 2014 I think this piece of code in callback function determines that the message came from input, If $nID = $IP Then $hCtrl = $lParam If $nNotifyCode = $EN_CHANGE Then $txt = GUICtrlRead($IP) For $n = 1 To UBound($MyVal) - 1 If StringCompare(StringLeft($MyVal[$n], StringLen($txt)), $txt) = 0 Then GUICtrlSetData($Edit1, $MyVal[$n]) if GUICtrlRead($IP) then GUICtrlSetState($Edit1, $GUI_show) else GUICtrlSetState($Edit1, $GUI_Hide) endif ExitLoop EndIf Next EndIf EndIf you might have to code another condition for your list box. That part seems to be working, so it only shows the list box if there is something in the input box... What i'm struggling with now is the SQL query. When I do a search, and try to move the data returned by the SQL Query, only 1 or 2 records come back, but if I run the same query in SQLCMD, I get several returns... The issue seems to be in here: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #include <Array.au3> global $MyVal $conn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=1.2.3.4;DATABASE=inventory;uid=inventory;pwd=MyPassWord;" $conn.Open($DSN) $rs = ObjCreate("ADODB.RecordSet") ;$rs.Open("SELECT Serial FROM tbl_Manual", $conn); To grab everything $rs.Open("SELECT TOP 20 Serial FROM tbl_Manual", $conn); to grab only 20 results just for testing While $rs.eof <> True ;ConsoleWrite($rs.Fields("Serial").Value & @CRLF); <~~ this works to bring data to the console For $x In $rs.Fields $MyVal = $MyVal & $x.name & "|"; <~~ This is supposed to populate $MyVal with the results with a pipe between them Next $x.MoveNext Wend $RS.Close $conn.close ;$MyVal = "fracturing|enzygotic|bondwoman|mealtime|miketime|kimball|kiteball|unreelable|aruspices|prevoted|punt|taxis"; I only use this for demoing the input box with random word values. $MyVal = StringSplit($MyVal,"|"); Splits the string at the pipe to make an array local $MyVal2 = $MyVal Msgbox(0,"MyVal", $MyVal) _ArrayDisplay($MyVal, "2"); Just so I can see what comes back, for testing only. Ill remove it on the final script GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") $gui = GUICreate("My GUI edit") $IP = GUICtrlCreateInput("", 10, 18, 200, 22) $Edit1 = GUICtrlCreateList("", 10, 40, 200, 177) GUICtrlSetLimit(-1, 20) GUICtrlSetState($Edit1, $GUI_Hide) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func WM_COMMAND($hWnd, $msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) If $nID = $IP Then $hCtrl = $lParam If $nNotifyCode = $EN_CHANGE Then $txt = GUICtrlRead($IP) For $n = 1 To UBound($MyVal) - 1 ;Msgbox(0,"Records found: " & $n, $MyVal[$n]) If StringCompare(StringLeft($MyVal[$n], StringLen($txt)), $txt) = 0 Then GUICtrlSetData($Edit1, $MyVal[$n]) if GUICtrlRead($IP) then GUICtrlSetState($Edit1, $GUI_show) else GUICtrlSetState($Edit1, $GUI_Hide) endif ExitLoop EndIf Next EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND C0d3 is P0etry( ͡° ͜ʖ ͡°)
Moderators Melba23 Posted January 14, 2014 Moderators Posted January 14, 2014 Kovacic,Does this help at all? expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> #Include <GuiListBox.au3> Global $hGUI, $hInput, $hList, $sPartialData, $asKeyWords[100] ; Create list full of random 5 character "words" Keywords() $hGUI = GUICreate("Example", 200, 400) $hInput = GUICtrlCreateInput("", 5, 5, 190, 20) $hList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) $hButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2]=[["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER]] GUISetAccelerators($AccelKeys) $sCurr_Input = "" $iCurrIndex = -1 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList $sChosen = GUICtrlRead($hList) If $sChosen <> "" Then GUICtrlSetData($hInput, $sChosen) Case $hButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($hInput) If _ArraySearch($asKeyWords, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $hUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($hList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($hList, $iCurrIndex) GUICtrlSetData($hInput, $sText) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf EndSwitch ; If input has changed, refill list with matching items If GUICtrlRead($hInput) <> $sCurr_Input Then CheckInputText() $sCurr_Input = GUICtrlRead($hInput) EndIf WEnd Func CheckInputText() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($hInput) If $sInput <> "" Then For $i = 0 To 99 If StringInStr($asKeyWords[$i], $sInput) <> 0 Then $sPartialData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func Keywords() Local $sData For $i = 0 To 99 $asKeyWords[$i] = Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) $sData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndFunc ;==>KeywordsPlease ask if anything is unclear. M23 Kovacic 1 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
Kovacic Posted January 14, 2014 Author Posted January 14, 2014 Kovacic, Does this help at all? expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> #Include <GuiListBox.au3> Global $hGUI, $hInput, $hList, $sPartialData, $asKeyWords[100] ; Create list full of random 5 character "words" Keywords() $hGUI = GUICreate("Example", 200, 400) $hInput = GUICtrlCreateInput("", 5, 5, 190, 20) $hList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) $hButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2]=[["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER]] GUISetAccelerators($AccelKeys) $sCurr_Input = "" $iCurrIndex = -1 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList $sChosen = GUICtrlRead($hList) If $sChosen <> "" Then GUICtrlSetData($hInput, $sChosen) Case $hButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($hInput) If _ArraySearch($asKeyWords, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $hUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($hList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($hList, $iCurrIndex) GUICtrlSetData($hInput, $sText) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf EndSwitch ; If input has changed, refill list with matching items If GUICtrlRead($hInput) <> $sCurr_Input Then CheckInputText() $sCurr_Input = GUICtrlRead($hInput) EndIf WEnd Func CheckInputText() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($hInput) If $sInput <> "" Then For $i = 0 To 99 If StringInStr($asKeyWords[$i], $sInput) <> 0 Then $sPartialData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func Keywords() Local $sData For $i = 0 To 99 $asKeyWords[$i] = Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) $sData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndFunc ;==>Keywords Please ask if anything is unclear. M23 This helps very much!! Thank you!! I can use the portion where you click on the result to have it populate the input box! too awesome thanks!! This SQL portion is eating me alive... this is the spot I'm stuck with at the moment... ... If $RS.RecordCount Then While Not $RS.EOF local $MyVal = $MyVal & StringStripWS($rs.Fields("Serial").value,8) & "|" $RS.MoveNext WEnd EndIf ... Which is just a piece of the code i posted earlier.. I know I'm doing something wrong here... when I execute the query in SQLCMD I get a nice array of data back. I am trying to now move that to an array which will essentially populate the word list. This way, once an object is chosen, its full details will come up.. when seems to be happening is, the array that is being returned is only the last record being returned from SQL... i.e. SQL returns: MyComputers ---------------------- compu1 compu2 compu3 compu4 compu5 compu6 compu7 compu8 compu9 when I dump the array, im getting: [0] = "2" [1] = "compu9" [2] = "" I have a feeling its where I dump the SQL into the variable, but all the research I have done shows it should be correct. C0d3 is P0etry( ͡° ͜ʖ ͡°)
Solution Kovacic Posted January 14, 2014 Author Solution Posted January 14, 2014 MISSION ACCOMPLISHED! Except for the SQL stuff I took out, this has now reached awesome! Enjoy! expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> #Include <GuiListBox.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> Global $hGUI Global $hInput Global $hList Global $sPartialData Global $output = '' Local $conn = ObjCreate( "ADODB.Connection" ) Local $DSN = "DRIVER={SQL Server};SERVER=MyServer;DATABASE=MyDB;uid=MyUID;pwd=MyPaSsWoRd;" SQLQuery() $hGUI = GUICreate("Example", 200, 400) $hInput = GUICtrlCreateInput("", 5, 5, 190, 20) $hList = GUICtrlCreateList("", 5, 30, 190, 225, BitOR(0x00100000, 0x00200000)) GUICtrlSetLimit(-1, 20) GUICtrlSetState($hList, $GUI_Hide) $hButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) Dim $AccelKeys[3][2]=[["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER]] GUISetAccelerators($AccelKeys) $sCurr_Input = "" $iCurrIndex = -1 GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList $sChosen = GUICtrlRead($hList) If $sChosen <> "" Then GUICtrlSetData($hInput, $sChosen) GUICtrlSetState($hList, $GUI_Hide) endif Case $hButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($hInput) If _ArraySearch($MyVal, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $hUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($hList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($hList, $iCurrIndex) GUICtrlSetData($hInput, $sText) GUICtrlSetState($hList, $GUI_Hide) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf EndSwitch If GUICtrlRead($hInput) <> $sCurr_Input Then CheckInputText() $sCurr_Input = GUICtrlRead($hInput) EndIf WEnd Func CheckInputText() $sPartialData = "|" Local $sInput = GUICtrlRead($hInput) If $sInput <> "" Then For $i = 0 To Ubound($MyVal) - 1 If StringInStr($MyVal[$i], $sInput) <> 0 Then $sPartialData &= $MyVal[$i] & "|" Next GUICtrlSetData($hList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func WM_COMMAND($hWnd, $msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) If $nID = $hInput Then $hCtrl = $lParam If $nNotifyCode = $EN_CHANGE Then $txt = GUICtrlRead($hInput) For $n = 1 To UBound($MyVal) - 1 ;Msgbox(0,"Records found: " & $n, $MyVal[$n]) If StringCompare(StringLeft($MyVal[$n], StringLen($txt)), $txt) = 0 Then GUICtrlSetData($hList, $MyVal[$n]) if GUICtrlRead($hInput) then GUICtrlSetState($hList, $GUI_show) else GUICtrlSetState($hList, $GUI_Hide) endif ExitLoop EndIf Next EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func SQLQuery() $conn.Open($DSN) $rs = ObjCreate( "ADODB.RecordSet" ) $rs.Open( "@@ PUT QUERY HERE @@", $conn ) If $RS.RecordCount Then While Not $RS.EOF $output = $output & StringStripWS($RS.Fields("@@ PUT TABLE HERE @@").Value,8) & "|" ; value of 4 columns on this line $RS.MoveNext WEnd EndIf global $MyVal = StringSplit($output,"|") $conn.close $sData = $output GUICtrlSetData($hList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndFunc Thank you everyone of the help! And if anyone is dealing with SQL issues and searches, go ahead and use this. Dont forget to put the query and table at the bottom replacing the @@ signs dmob and MarkIT 2 C0d3 is P0etry( ͡° ͜ʖ ͡°)
ferradavi Posted May 20, 2016 Posted May 20, 2016 Hi everybody. How to transform the following static list $hList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) in a "popup menu" in Melba23's script ? Thanks
gcue Posted December 29, 2016 Posted December 29, 2016 On 1/14/2014 at 7:58 AM, Melba23 said: Kovacic, Does this help at all? expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> #Include <GuiListBox.au3> Global $hGUI, $hInput, $hList, $sPartialData, $asKeyWords[100] ; Create list full of random 5 character "words" Keywords() $hGUI = GUICreate("Example", 200, 400) $hInput = GUICtrlCreateInput("", 5, 5, 190, 20) $hList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) $hButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2]=[["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER]] GUISetAccelerators($AccelKeys) $sCurr_Input = "" $iCurrIndex = -1 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList $sChosen = GUICtrlRead($hList) If $sChosen <> "" Then GUICtrlSetData($hInput, $sChosen) Case $hButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($hInput) If _ArraySearch($asKeyWords, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $hUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($hList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($hList, $iCurrIndex) GUICtrlSetData($hInput, $sText) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf EndSwitch ; If input has changed, refill list with matching items If GUICtrlRead($hInput) <> $sCurr_Input Then CheckInputText() $sCurr_Input = GUICtrlRead($hInput) EndIf WEnd Func CheckInputText() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($hInput) If $sInput <> "" Then For $i = 0 To 99 If StringInStr($asKeyWords[$i], $sInput) <> 0 Then $sPartialData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func Keywords() Local $sData For $i = 0 To 99 $asKeyWords[$i] = Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) $sData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndFunc ;==>Keywords Please ask if anything is unclear. M23 thank you Melba for this awesome script. works great, except would it be possible to stay out of the while loop and do it instead with wm_notify? i was also thinking of doing it in a combo box to simulate the searches in google.com thanks again
gcue Posted December 29, 2016 Posted December 29, 2016 nvm i think i found another example thanks anyway.. happy holidays
Moderators Melba23 Posted December 29, 2016 Moderators Posted December 29, 2016 gcue, Quote would it be possible to stay out of the while loop and do it instead with wm_notify? You actually need WM_COMMAND: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Array.au3> #Include <GuiListBox.au3> Global $hGUI, $cInput, $cList, $sPartialData, $asKeyWords[100] ; Create list full of random 5 character "words" Keywords() $hGUI = GUICreate("Example", 200, 400) $cInput = GUICtrlCreateInput("", 5, 5, 190, 20) $cList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) $cButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $cUP = GUICtrlCreateDummy() $cDOWN = GUICtrlCreateDummy() $cENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2]=[["{UP}", $cUP], ["{DOWN}", $cDOWN], ["{ENTER}", $cENTER]] GUISetAccelerators($AccelKeys) $iCurrIndex = -1 GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cList $sChosen = GUICtrlRead($cList) If $sChosen <> "" Then GUICtrlSetData($cInput, $sChosen) Case $cButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($cInput) If _ArraySearch($asKeyWords, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $cUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf Case $cDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($cList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf Case $cENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($cList, $iCurrIndex) GUICtrlSetData($cInput, $sText) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf EndSwitch WEnd Func CheckInputText() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($cInput) If $sInput <> "" Then For $i = 0 To 99 If StringInStr($asKeyWords[$i], $sInput) <> 0 Then $sPartialData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($cList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func Keywords() Local $sData For $i = 0 To 99 $asKeyWords[$i] = Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) $sData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($cList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndFunc ;==>Keywords Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) ; If it was an update message from our input If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $cInput Then CheckInputText() EndIf EndFunc And if you want to do something similar with a combo, I suggest looking at _GUICtrlComboBox_AutoComplete in the Help file. M23 ioa747 1 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
gcue Posted December 29, 2016 Posted December 29, 2016 right thats what i meant... wm_command thank you again for your help
BUNNY3005 Posted August 20, 2018 Posted August 20, 2018 instead of characters, I have to search for files. Can you tell me how to do?
Moderators Melba23 Posted August 20, 2018 Moderators Posted August 20, 2018 BUNNY3005, The principle is exactly the same - just fill the array with the filenames rather then the random letters. Give it a go and see what happens - you know where we are if you run into problems. M23 BUNNY3005 1 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
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