Sign in to follow this  
Followers 0
Paulie

Refining Filter Help

12 posts in this topic

#1 ·  Posted (edited)

I don't know if it has been done before(Couldn't find an answer in my search), but basically, I'm trying to filter a list view in live time. I have a list that takes three strings that contain all the built in autoit functions and puts them in a list view, and i have an input, which i am trying to have act as a filter.

Sort of like the index on the autoit help file, i'm trying to have it take what has been entered into the input, and remove items from the list view that don't start the same way.

The code I have now has two main problems, it starts off with a blank list and adds to it as the input is filled. I want it to have a full list of all the functions if the input is empty.

Second is the incredible flicker, Currently, sending the letter 'a' alone to this input causes the list to flicker so much that it is almost unbearable to look at

Heres my code,

#include <GUIConstants.au3>
#region Function Strings
Global $String1 = "Abs|ACos|AdlibDisable|AdlibEnable|Asc|ASin|Assign|ATan|AutoItSetOption|AutoItWinGetTitle|AutoItWinSetTitle|Beep"& _
    "|BinaryString|BitAND|BitNOT|BitOR|BitRotate|BitShift|BitXOR|BlockInput|Break|Call|CDTray|Ceiling|Chr|ClipGet|ClipPut|ConsoleRead"& _
    "|ConsoleWrite|ConsoleWriteError|ControlClick|ControlCommand|ControlDisable|ControlEnable|ControlFocus|ControlGetFocus|ControlGetHandle"& _
    "|ControlGetPos|ControlGetText|ControlHide|ControlListView|ControlMove|ControlSend|ControlSetText|ControlShow|Cos|Dec|DirCopy|DirCreate"& _
    "|DirGetSize|DirMove|DirRemove|DllCall|DllClose|DllOpen|DllStructCreate|DllStructGetData|DllStructGetPtr|DllStructGetSize|DllStructSetData"& _
    "|DriveGetDrive|DriveGetFileSystem|DriveGetLabel|DriveGetSerial|DriveGetType|DriveMapAdd|DriveMapDel|DriveMapGet|DriveSetLabel|DriveSpaceFree"& _
    "|DriveSpaceTotal|DriveStatus|EnvGet|EnvSet|EnvUpdate|Eval|Execute|Exp|FileChangeDir|FileClose|FileCopy|FileCreateNTFSLink|FileCreateShortcut"& _
    "|FileDelete|FileExists|FileFindFirstFile|FileFindNextFile|FileGetAttrib|FileGetLongName|FileGetShortcut|FileGetShortName|FileGetSize|FileGetTime"& _
    "|FileGetVersion|FileInstall|FileMove|FileOpen|FileOpenDialog|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileSaveDialog|FileSelectFolder"& _
    "|FileSetAttrib|FileSetTime|FileWrite|FileWriteLine|Floor|FtpSetProxy|GUICreate|GUICtrlCreateAvi|GUICtrlCreateButton|GUICtrlCreateCheckbox|GUICtrlCreateCombo"& _
    "|GUICtrlCreateContextMenu|GUICtrlCreateDate|GUICtrlCreateDummy|GUICtrlCreateEdit|GUICtrlCreateGraphic|GUICtrlCreateGroup|GUICtrlCreateIcon|GUICtrlCreateInput"& _
    "|GUICtrlCreateLabel|GUICtrlCreateList|GUICtrlCreateListView|GUICtrlCreateListViewItem|GUICtrlCreateMenu|GUICtrlCreateMenuitem|GUICtrlCreateMonthCal"& _
    "|GUICtrlCreateObj|GUICtrlCreatePic|GUICtrlCreateProgress|GUICtrlCreateRadio|GUICtrlCreateSlider|GUICtrlCreateTab|GUICtrlCreateTabItem|GUICtrlCreateTreeView"& _
    "|GUICtrlCreateTreeViewItem|GUICtrlCreateUpdown|GUICtrlDelete|GUICtrlGetHandle|GUICtrlGetState|GUICtrlRead|GUICtrlRecvMsg|GUICtrlRegisterListViewSort|GUICtrlSendMsg|";;
Global $String2 =   "GUICtrlSendToDummy|GUICtrlSetBkColor|GUICtrlSetColor|GUICtrlSetCursor|GUICtrlSetData|GUICtrlSetFont|GUICtrlSetGraphic|GUICtrlSetImage|GUICtrlSetLimit"& _
    "|GUICtrlSetOnEvent|GUICtrlSetPos|GUICtrlSetResizing|GUICtrlSetState|GUICtrlSetStyle|GUICtrlSetTip|GUIDelete|GUIGetCursorInfo|GUIGetMsg|GUIRegisterMsg"& _
    "|GUISetBkColor|GUISetCoord|GUISetCursor|GUISetFont|GUISetHelp|GUISetIcon|GUISetOnEvent|GUISetState|GUIStartGroup|GUISwitch|Hex|HotKeySet|HttpSetProxy"& _
    "|HWnd|InetGet|InetGetSize|IniDelete|IniRead|IniReadSection|IniReadSectionNames|IniRenameSection|IniWrite|InputBox|Int|IsAdmin|IsArray|IsBinaryString|IsBool"& _
    "|IsDeclared|IsFloat|IsHWnd|IsInt|IsKeyword|IsNumber|IsObj|IsString|Log|MemGetStats|Mod|MouseClick|MouseClickDrag|MouseDown|MouseGetCursor|MouseGetPos|MouseMove"& _
    "|MouseUp|MouseWheel|MsgBox|Number|ObjCreate|ObjEvent|ObjGet|ObjName|Ping|PixelChecksum|PixelGetColor|PixelSearch|ProcessClose|ProcessExists|ProcessList"& _
    "|ProcessSetPriority|ProcessWait|ProcessWaitClose|ProgressOff|ProgressOn|ProgressSet|Random|RegDelete|RegEnumKey|RegEnumVal|RegRead|RegWrite|Round|Run|RunAsSet"& _
    "|RunWait|Send|SetError|SetExtended|Shutdown|Sin|Sleep|SoundPlay|SoundSetWaveVolume|SplashImageOn|SplashOff|SplashTextOn|Sqrt|StatusbarGetText|StderrRead"& _
    "|StdinWrite|StdoutRead|String|StringAddCR|StringFormat|StringInStr|StringIsAlNum|StringIsAlpha|StringIsASCII|StringIsDigit|StringIsFloat|StringIsInt|StringIsLower"& _
    "|StringIsSpace|StringIsUpper|StringIsXDigit|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringStripCR|StringStripWS|StringTrimLeft"& _
    "|StringTrimRight|StringUpper|Tan|TCPAccept|TCPCloseSocket|TCPConnect|TCPListen|TCPNameToIP|TCPRecv|TCPSend|TCPShutdown,UDPShutdown|TCPStartup,UDPStartup|"
Global $String3 =   "TimerDiff|TimerInit|ToolTip|TrayCreateItem|TrayCreateMenu|TrayGetMsg|TrayItemDelete|TrayItemGetHandle|TrayItemGetState|TrayItemGetText|TrayItemSetOnEvent"& _
    "|TrayItemSetState|TrayItemSetText|TraySetClick|TraySetIcon|TraySetOnEvent|TraySetPauseIcon|TraySetState|TraySetToolTip|TrayTip|UBound|UDPBind|UDPCloseSocket"& _
    "|UDPOpen|UDPRecv|UDPSend|WinActivate|WinActive|WinClose|WinExists|WinFlash|WinGetCaretPos|WinGetClassList|WinGetClientSize|WinGetHandle|WinGetPos|WinGetProcess"& _
    "|WinGetState|WinGetText|WinGetTitle|WinKill|WinList|WinMenuSelectItem|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinSetOnTop|WinSetState|WinSetTitle|WinSetTrans"& _
    "|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive"
Global $List1 = StringSplit($String1, "|")
Global $List2 = StringSplit($String2, "|")
Global $List3 = StringSplit($String3, "|")
Global $Content= $String1&$String2&$String3
#endregion
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\desktop\toolbar.kxf
$Toolbar = GUICreate("QuickRef Function Poster", 201, 801, 1047, 93, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))
GUISetBkColor(0x716F64)
$ListView = GUICtrlCreateList("", 15, 120, 170, 538, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER), $WS_EX_STATICEDGE)
GUICtrlSetData(-1, $Content)
GUICtrlSetFont(-1, 8, 800, 0, "Rockwell")
GUICtrlSetBkColor(-1, 0xD4D0C8)
$Input = GUICtrlCreateInput("", 15, 96, 170, 22)
GUICtrlSetFont(-1, 9, 800, 0, "Rockwell")
$Accept = GUICtrlCreateButton("Add To Clipboard", 15, 688, 170, 30, 0)
GUICtrlCreateLabel("QuickRef Function Poster", 2, 16, 194, 22)
GUICtrlSetFont(-1, 11, 800, 0, "Rockwell")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x716F64)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $Search = GUICtrlRead($Input)
    For $a = 1 to $List1[0]
        If StringInStr($List1[$a],$Search) Then
            $Content = $Content&"|"&$List1[$a]
        EndIf
    Next
    For $b = 1 to $List2[0]
        If StringInStr($List2[$b],$Search) Then
            $Content = $Content&"|"&$List2[$b]
        EndIf
    Next
    For $c = 1 to $List3[0]
        If StringInStr($List3[$c],$Search) Then
            $Content = $Content&"|"&$List3[$c]
        EndIf
    Next
    GuiCtrlSetData($ListView, $Content)
    $Content = ""
    $nMsg = GUIGetMsg()
WEnd

EDIT: why are all my quotes being replaced with '& quote;'? is this just me or is it happening for everyone?

Edited by Paulie

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

No one can help me? No ideas? :lmao:

I'm sure this can't be done, but i don't know how...

*Bump*

Edited by Paulie

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

the script is really messed up... you should attach each string as a .txt so we can paste it into scite

for me, each line is unterminated and if i add "& _, the next line is unterminated, and i have to add another quote, then the next line is unterminated because of it...

><

edit: i got all the strings to work now the beep function doesnt work... that and i cant figure out what this is supposed to do anyway

might as well attach your script as a .au3, i think its the [autoit] format that causes it

Edited by Rad

Share this post


Link to post
Share on other sites

Good Idea did you resolve the flickering?


A decision is a powerful thing

Share this post


Link to post
Share on other sites

Zedna! Thanks! :)


A decision is a powerful thing

Share this post


Link to post
Share on other sites

Here's my solution

#include <GUIConstants.au3>
#include <ControlConstants.au3>
Opt ("GUIOnEventMode", 1)

#region Function Strings
Global $String1 = "Abs|ACos|AdlibDisable|AdlibEnable|Asc|ASin|Assign|ATan|AutoItSetOption|AutoItWinGetTitle|AutoItW

inSetTitle|Beep"& _
    "|BinaryString|BitAND|BitNOT|BitOR|BitRotate|BitShift|BitXOR|BlockInput|Break|Call|CDTray|Ceiling

|Chr|ClipGet|ClipPut|ConsoleRead"& _
    "|ConsoleWrite|ConsoleWriteError|ControlClick|ControlCommand|ControlDisable|ControlEnable|Control

Focus|ControlGetFocus|ControlGetHandle"& _
    "|ControlGetPos|ControlGetText|ControlHide|ControlListView|ControlMove|ControlSend|ControlSetText

|ControlShow|Cos|Dec|DirCopy|DirCreate"& _
    "|DirGetSize|DirMove|DirRemove|DllCall|DllClose|DllOpen|DllStructCreate|DllStructGetData|DllStruc

tGetPtr|DllStructGetSize|DllStructSetData"& _
    "|DriveGetDrive|DriveGetFileSystem|DriveGetLabel|DriveGetSerial|DriveGetType|DriveMapAdd|DriveMap

Del|DriveMapGet|DriveSetLabel|DriveSpaceFree"& _
    "|DriveSpaceTotal|DriveStatus|EnvGet|EnvSet|EnvUpdate|Eval|Execute|Exp|FileChangeDir|FileClose|Fi

leCopy|FileCreateNTFSLink|FileCreateShortcut"& _
    "|FileDelete|FileExists|FileFindFirstFile|FileFindNextFile|FileGetAttrib|FileGetLongName|FileGetS

hortcut|FileGetShortName|FileGetSize|FileGetTime"& _
    "|FileGetVersion|FileInstall|FileMove|FileOpen|FileOpenDialog|FileRead|FileReadLine|FileRecycle|F

ileRecycleEmpty|FileSaveDialog|FileSelectFolder"& _
    "|FileSetAttrib|FileSetTime|FileWrite|FileWriteLine|Floor|FtpSetProxy|GUICreate|GUICtrlCreateAvi|

GUICtrlCreateButton|GUICtrlCreateCheckbox|GUICtrlCreateCombo"& _
    "|GUICtrlCreateContextMenu|GUICtrlCreateDate|GUICtrlCreateDummy|GUICtrlCreateEdit|GUICtrlCreateGr

aphic|GUICtrlCreateGroup|GUICtrlCreateIcon|GUICtrlCreateInput"& _
    "|GUICtrlCreateLabel|GUICtrlCreateList|GUICtrlCreateListView|GUICtrlCreateListViewItem|GUICtrlCre

ateMenu|GUICtrlCreateMenuitem|GUICtrlCreateMonthCal"& _
    "|GUICtrlCreateObj|GUICtrlCreatePic|GUICtrlCreateProgress|GUICtrlCreateRadio|GUICtrlCreateSlider|

GUICtrlCreateTab|GUICtrlCreateTabItem|GUICtrlCreateTreeView"& _
    "|GUICtrlCreateTreeViewItem|GUICtrlCreateUpdown|GUICtrlDelete|GUICtrlGetHandle|GUICtrlGetState|GU

ICtrlRead|GUICtrlRecvMsg|GUICtrlRegisterListViewSort|GUICtrlSendMsg|";;
Global $String2 =   "GUICtrlSendToDummy|GUICtrlSetBkColor|GUICtrlSetColor|GUICtrlSetCursor|GUICtrlSetData|GUICtrlSetF

ont|GUICtrlSetGraphic|GUICtrlSetImage|GUICtrlSetLimit"& _
    "|GUICtrlSetOnEvent|GUICtrlSetPos|GUICtrlSetResizing|GUICtrlSetState|GUICtrlSetStyle|GUICtrlSetTi

p|GUIDelete|GUIGetCursorInfo|GUIGetMsg|GUIRegisterMsg"& _
    "|GUISetBkColor|GUISetCoord|GUISetCursor|GUISetFont|GUISetHelp|GUISetIcon|GUISetOnEvent|GUISetSta

te|GUIStartGroup|GUISwitch|Hex|HotKeySet|HttpSetProxy"& _
    "|HWnd|InetGet|InetGetSize|IniDelete|IniRead|IniReadSection|IniReadSectionNames|IniRenameSection|

IniWrite|InputBox|Int|IsAdmin|IsArray|IsBinaryString|IsBool"& _
    "|IsDeclared|IsFloat|IsHWnd|IsInt|IsKeyword|IsNumber|IsObj|IsString|Log|MemGetStats|Mod|MouseClic

k|MouseClickDrag|MouseDown|MouseGetCursor|MouseGetPos|MouseMove"& _
    "|MouseUp|MouseWheel|MsgBox|Number|ObjCreate|ObjEvent|ObjGet|ObjName|Ping|PixelChecksum|PixelGetC

olor|PixelSearch|ProcessClose|ProcessExists|ProcessList"& _
    "|ProcessSetPriority|ProcessWait|ProcessWaitClose|ProgressOff|ProgressOn|ProgressSet|Random|RegDe

lete|RegEnumKey|RegEnumVal|RegRead|RegWrite|Round|Run|RunAsSet"& _
    "|RunWait|Send|SetError|SetExtended|Shutdown|Sin|Sleep|SoundPlay|SoundSetWaveVolume|SplashImageOn

|SplashOff|SplashTextOn|Sqrt|StatusbarGetText|StderrRead"& _
    "|StdinWrite|StdoutRead|String|StringAddCR|StringFormat|StringInStr|StringIsAlNum|StringIsAlpha|S

tringIsASCII|StringIsDigit|StringIsFloat|StringIsInt|StringIsLower"& _
    "|StringIsSpace|StringIsUpper|StringIsXDigit|StringLeft|StringLen|StringLower|StringMid|StringRep

lace|StringRight|StringSplit|StringStripCR|StringStripWS|StringTrimLeft"& _
    "|StringTrimRight|StringUpper|Tan|TCPAccept|TCPCloseSocket|TCPConnect|TCPListen|TCPNameToIP|TCPRe

cv|TCPSend|TCPShutdown,UDPShutdown|TCPStartup,UDPStartup|"
Global $String3 =   "TimerDiff|TimerInit|ToolTip|TrayCreateItem|TrayCreateMenu|TrayGetMsg|TrayItemDelete|TrayItemGetH

andle|TrayItemGetState|TrayItemGetText|TrayItemSetOnEvent"& _
    "|TrayItemSetState|TrayItemSetText|TraySetClick|TraySetIcon|TraySetOnEvent|TraySetPauseIcon|TrayS

etState|TraySetToolTip|TrayTip|UBound|UDPBind|UDPCloseSocket"& _
    "|UDPOpen|UDPRecv|UDPSend|WinActivate|WinActive|WinClose|WinExists|WinFlash|WinGetCaretPos|WinGet

ClassList|WinGetClientSize|WinGetHandle|WinGetPos|WinGetProcess"& _
    "|WinGetState|WinGetText|WinGetTitle|WinKill|WinList|WinMenuSelectItem|WinMinimizeAll|WinMinimize

AllUndo|WinMove|WinSetOnTop|WinSetState|WinSetTitle|WinSetTrans"& _
    "|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive"
Global $List1 = StringSplit($String1, "|")
Global $List2 = StringSplit($String2, "|")
Global $List3 = StringSplit($String3, "|")
Global $Content= $String1&$String2&$String3
#endregion
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\desktop\toolbar.kxf
$Toolbar = GUICreate("QuickRef Function Poster", 201, 801, 1047, 93, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))
GUISetBkColor(0x716F64)
$ListView = GUICtrlCreateList("", 15, 120, 170, 538, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER), $WS_EX_STATICEDGE)
GUICtrlSetData(-1, $Content)
GUICtrlSetFont(-1, 8, 800, 0, "Rockwell")
GUICtrlSetBkColor(-1, 0xD4D0C8)
$Input = GUICtrlCreateInput("", 15, 96, 170, 22)
GUICtrlSetFont(-1, 9, 800, 0, "Rockwell")
$Accept = GUICtrlCreateButton("Add To Clipboard", 15, 688, 170, 30, 0)
GUICtrlCreateLabel("QuickRef Function Poster", 2, 16, 194, 22)
GUICtrlSetFont(-1, 11, 800, 0, "Rockwell")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x716F64)

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "_GUIEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "_GUIEvents")

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    
   Sleep(25)
WEnd

Func _FilterLV()
    $Search = GUICtrlRead($Input)
    For $a = 1 to $List1[0]
        If StringInStr($List1[$a],$Search) Then
            $Content = $Content&"|"&$List1[$a]
        EndIf
    Next
    For $b = 1 to $List2[0]
        If StringInStr($List2[$b],$Search) Then
            $Content = $Content&"|"&$List2[$b]
        EndIf
    Next
    For $c = 1 to $List3[0]
        If StringInStr($List3[$c],$Search) Then
            $Content = $Content&"|"&$List3[$c]
        EndIf
    Next
    GuiCtrlSetData($ListView, $Content)
    $Content = ""
EndFunc


Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
   ; gaFrost for monitoring inputfield change
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0xFFFF)
    Local $hCtrl = $lParam

    Switch $nID
        Case $Input
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _FilterLV()     
            EndSwitch
    EndSwitch
   ; Proceed the default Autoit3 internal message commands.
   ; You also can complete let the line out.
   ; !!! But only 'Return' (without any value) will not proceed
   ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc  ;==>MY_WM_COMMAND


Func _GUIEvents()
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
            Exit        
            
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
            
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE
            
    EndSelect
    
EndFunc

A decision is a powerful thing

Share this post


Link to post
Share on other sites

What in the world is ControlConstants.au3?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

What in the world is ControlConstants.au3?

My apologies. It's one that I reuse all the time.

see attached


A decision is a powerful thing

Share this post


Link to post
Share on other sites

My apologies. It's one that I reuse all the time.

see attached

It was only 1 global, could have just done:
Global Const $EN_CHANGE = 0x300;#include <ControlConstants.au3>
At the top.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

It was only 1 global, could have just done:

Global Const $EN_CHANGE = 0x300;#include <ControlConstants.au3>
At the top.
Smoke_N, I know. As I said, I just use ControlConstants.au3 all the time. I remove any control constants from the script and include controlconstants.au3 to make sure I have the ones in the script. If I don't have them, then I add them to my script. I do this during testing in case I expand the script to use more control constants. For this script I could have removed it since it was just containing that one. However, I didn't think of it and I was just showing the general idea of what I did. I wasn't intending a general release. Just an example script. Obviously it's not a good one because I didn't even attach the controlconstants.au3 to begin with.

Hope that clarifies what I was thinking when I originally made that post. Yes, simply one could just replace my include.


A decision is a powerful thing

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0