monsterkodi Posted November 12, 2009 Share Posted November 12, 2009 Hello, if a ListView or TreeView has the keyboard focus and i start typing, the item that starts with the typed letters gets selected. A new search is started when there is no keyboard input for approximately 1-2 seconds. I would like to know if it is possible to set the duration of this delay somehow. I would also like to know if there is a way to receive the pressed keys. The documentation states that these Controls swallow the WM_KEYDOWN messages. Is there no way to receive them in my script nevertheless? Thanks in advance for any answer, yours kodi Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 13, 2009 Moderators Share Posted November 13, 2009 (edited) monsterkodi,First, welcome to the AutoIt forums. Here is a first second cut at what you wanted. The only thing I cannot resolve is that the first item is always selected when you start - seems like a default setting and I have seen it remarked upon elsewhere in these forums. expandcollapse popup#include <GUIConstantsEx.au3> #include <ListviewConstants.au3> #Include <GuiListView.au3> #include <String.au3> ; Create GUI $hGUI = GUICreate("Test", 500, 500) ; Create LV $hListView = GUICtrlCreateListView(" ", 10, 10, 200, 220) GUICtrlSetBkColor(-1, 0x0AFFB0) ; Fill LV For $i = 0 To 9 GUICtrlCreateListViewItem(_StringRepeat(Chr(65 + $i), 7), $hListView) Next ; Create Input $hInput = GUICtrlCreateInput("", 250, 10, 200, 20) GUISetState() ; Set up LV search structure $tInfo = DllStructCreate($tagLVFINDINFO) DllStructSetData($tInfo, "Flags", $LVFI_PARTIAL) ; Looking for partial matches ; Set intitial values $iOld_Index = -1 $sCurr_Input = GUICtrlRead($hInput) $iBegin = TimerInit() While 1 ; Look for [X} click Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; Reset Input if no change in 2 secs ; Wait until 2 secs have passed If TimerDiff($iBegin) > 2000 Then ; If no change to Input value If GUICtrlRead($hInput) = $sCurr_Input Then ; Reset Input GUICtrlSetData($hInput, "") ; Clear all selection in LV _GUICtrlListView_SetItemSelected($hListView, -1, False) Else ; If value has changed, store current input and reset timer $sCurr_Input = GUICtrlRead($hInput) $iBegin = TimerInit() EndIf EndIf ; Search the LV for element containing Inpit content $iIndex = _GUICtrlListView_FindItem($hListView, -1, $tInfo, GUICtrlRead($hInput)) ; If the selection has changed If $iIndex <> $iOld_Index Then ; Clear old selection in LV and set new one _GUICtrlListView_SetItemSelected($hListView, -1, False) _GUICtrlListView_SetItemSelected($hListView, $iIndex) ; Store current selection $iOld_Index = $iIndex EndIf WEndAs to receiving the pressed keys, I am unsure what exactly you mean. You can read what is in the Input by using GUICtrlRead, as you can see in the script. Is that enough? I should warn you that keyloggers (saving every key pressed) are very much NOT welcome here because of the obvious possibilites of malicious use.M23Edit: Updated and improved script example removing some earlier problems. Edited November 13, 2009 by Melba23 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...
monsterkodi Posted November 13, 2009 Author Share Posted November 13, 2009 Hello M23, thanks for your welcome and your script. Unfortunately, it isn't quite what I expected. I don't really want to re-implement the tree view navigation. I would like to leave the focus in the tree view and just change the delay after which the search string gets resetted. While browsing the MSDN, i found a solution to my second question: sending a TVM_GETISEARCHSTRING message will retrieve the search string. But that also tells me that the incremental search is done in a part controlled by Microsoft, not by AutoIt, and therefore probably not tweakable without the corresponding interface. After all, maybe I have to do it your way in the end. Thanks again for your help and a general sorry to everybody for starting this thread in the wrong section (just discovered the UI topic ) yours kodi Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 13, 2009 Moderators Share Posted November 13, 2009 monsterkodi,your script. Unfortunately, it isn't quite what I expectedJust to make sure you realise that normally we expect you to make an effort at coding something yourself first before we chip in with suggestions. I was being extra nice to welcome you to the forums - as Sir Percy said to Courtney "Do not expect treats like this every day"! 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...
monsterkodi Posted November 13, 2009 Author Share Posted November 13, 2009 Hello M23, I sense some misunderstanding here. I really appreciate your help. You provided a workaround for my problem because it probably can't be solved directly, which is very nice of you. I don't expect treats like this every day, please forgive me my bad wording. Peace, yours kodi Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 13, 2009 Moderators Share Posted November 13, 2009 monsterkodi, Peace to you too. 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...
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