Help with Search Box for ListView Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Help with Search Box for ListView

08 Jun 2020, 05:10

The code below finding a text on Edit box using kind of "Search Box":

Code: Select all

; a little gui with some text from the manual
Gui 1:Add, Button, gFindString, Search
Gui 1:Add, Edit, w100 vfind
Gui 1:Add, Edit, w330 r3 vContent HSCROLL
Gui 1:Add, StatusBar,, Ctrl+F to search
SB_SetParts(300)
GuiControl, Hide, Button1
GuiControl, Hide, Edit1
Gui 1:Show,, FindSample
WinGet ControlID, ID, FindSample

someText=
(
Creating a script
Each script is a plain text file containing commands
to be executed by the program (AutoHotkey.exe).
A script may also contain hotkeys and hotstrings, or
even consist entirely of them. However, in the absence
of hotkeys and hotstrings, a script will perform its
commands sequentially from top to bottom the moment
it is launched.

To create a new script:

Open Windows Explorer and navigate to a folder of
your choice.
Pull down the File menu and choose New >> AutoHotkey
Script (or Text Document).
Type a name for the file, ensuring that it ends in .ahk.
For example: Test.ahk
Right-click the file and choose Edit Script.
On a new blank line, type the following:
#space::Run www.google.com
The symbol # stands for the Windows key, so #space means
holding down the Windows key then pressing the spacebar
to activate a hotkey. The :: means that the subsequent
command should be executed whenever this hotkey is
pressed, in this case to go to the Google web site.
To try out this script, continue as follows:

Save and close the file.
In Windows Explorer, double-click the script to launch
it. A new tray icon appears. Hold down the Windows key
and press the spacebar. A web page opens in the default
browser.
To exit or edit the script, right click its tray icon.
Note: Multiple scripts can be running simultaneously,
each with its own tray icon. Furthermore, each script
can have multiple hotkeys and hotstrings.
)
Guicontrol,,Edit2, %someText%
return

FindString:
   Gui, Submit, Nohide

   if (find != lastFind) {
    offset = 0
    hits = 0
   }

   GuiControl 1:Focus, Content                           ; focus on main help window to show selection
   SendMessage 0xB6, 0, -999, Edit2, ahk_id %ControlID%  ; Scroll to top
   StringGetPos pos, Content, %find% ,,offset            ; find the position of the search string
   if (pos = -1) {
    if (offset = 0) {
      SB_SetText("'" . find . "' not found", 1)
      SB_SetText("", 2)
    }
    else {
      SB_SetText("No more occurrences of '" . find . "'")
      SB_SetText("", 2)
      offset = 0
      hits = 0
    }
    return
   }
   StringLeft __s, Content, %pos%                        ; cut off end to count lines
   StringReplace __s,__s,`n,`n,UseErrorLevel             ; Errorlevel <- line number
   addToPos=%Errorlevel%
   SendMessage 0xB6, 0, ErrorLevel, Edit2, ahk_id %ControlID% ; Scroll to visible
   SendMessage 0xB1, pos + addToPos, pos + addToPos + Strlen(find), Edit2, ahk_id %ControlID% ; Select search text
   ; http://msdn.microsoft.com/en-us/library/bb761637(VS.85).aspx
   ; Scroll the caret into view in an edit control:
   SendMessage, EM_SCROLLCARET := 0xB7, 0, 0, Edit2, ahk_id %ControlID%
   offset := pos + addToPos + Strlen(find)
   lastFind = %find%
   hits++
   SB_SetText("'" . find . "' found in line " . addToPos + 1, 1)
   SB_SetText(hits . (hits = 1 ? " hit" : " hits"), 2)
Return

^f::
GuiControl, Show, Button1
GuiControl, Show, Edit1
Sleep 100
ControlFocus, Edit1, A
Return
i want to make the same for ListView so it would mark the finded row on the listview

Code: Select all

vDir1 = c:

Gui,2:default
Gui 2:Add, Button,gSearch, Search
Gui 2:Add, Edit, w100 vfind
Gui,2: Add , ListView, r25 w323 backgroundGray cYellow grid vLV1 gLV1a altsubmit Multi, #|%vDir1%|Fullpath|Date
LV_ModifyCol(1,0)
LV_ModifyCol(2,200)
LV_ModifyCol(3,0)
LV_ModifyCol(4,100)
LV_ModifyCol(1,"integer")
LV_ModifyCol(2,"left")
LV_ModifyCol(4,"digit")
LV_ModifyCol(4, "left") 
Gui,2: Show
gosub,fill
return
exitapp


Fill:
Gui,2: Submit, Nohide

Loop, 2
	Gui,2:ListView, LV%A_Index%

ib=0
LV_Delete()
Loop, Files, % vDir1 "\*", D                        ;- folders
{
	if A_LoopFileName in %foldersBlacklist%
	{
		excludedFolders .= """" . A_LoopFileFullPath . """ "
		continue
	}
   ib++	
   SplitPath,A_LoopFileFullPath, name, dir, ext, name_no_ext, drive
   LV_Add("",ib,name,A_LoopFileFullPath,a_loopfiletimemodified)

}
LV_ModifyCol(4, "Logical SortDesc") 
return
;----------------

LV1a:
Gui,2: Submit, Nohide

Loop, 2
	Gui,2:ListView, LV%A_Index%

RC:=LV_GetNext("C")
RF:=LV_GetNext("F")
GC:=LV_GetCount()
  If A_GuiEvent=Doubleclick
     {
     LV_GetText(C1,A_EventInfo,1)
     LV_GetText(C2,A_EventInfo,2)
     LV_GetText(C3,A_EventInfo,3)
     LV_GetText(C4,A_EventInfo,4)
     path := c3
	 ;~ msgbox, %path%
	 goto, goit!
     return
     }
return

goit!:
msgbox, %path%
return

Search:
MsgBox, help me to mark the finded row on the listview

thanks in advance!
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: Help with Search Box for ListView

08 Jun 2020, 11:03

search in Listview , but not same search like in Edit

Code: Select all

;- Help with Search Box for ListView 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=77040

vDir1 = c:
Gui,2:default
Gui 2:Add, Button,gShowAll,ShowAll
Gui 2:Add, Button,gSearch, Search
Gui 2:Add, Edit, w100 vfind
;Gui 2:Add, Edit, w100 vfind gSearch   ;- or maybe
Gui,2: Add , ListView, r25 w323 backgroundGray cYellow grid vLV1 gLV1a altsubmit Multi, #|%vDir1%|Fullpath|Date
LV_ModifyCol(1,0),LV_ModifyCol(2,200),LV_ModifyCol(3,0),LV_ModifyCol(4,100),LV_ModifyCol(1,"integer"),LV_ModifyCol(2,"left"),LV_ModifyCol(4,"digit"),LV_ModifyCol(4, "left") 
Gui,2: Show
gosub,fill
return
;---------------------
2Guiclose:
exitapp
esc::exitapp
;---------------------
;----------------------------
Showall:
Guicontrol,2:,Find
Search:
Gui,2:default
Gui,2:submit,nohide
Gui,2:ListView, LV1
SetKeyDelay,20,20
LV_Delete()
IB=0
GuiControl,2: -Redraw,LV1
Loop, Files, % vDir1 "\*", D                        ;- folders
 {
   ib++	
   SplitPath,A_LoopFileFullPath, name, dir, ext, name_no_ext, drive
   if instr(name,find)
     LV_Add("",ib,name,A_LoopFileFullPath,a_loopfiletimemodified)
 }
GuiControl,2: +Redraw,LV1
LV_ModifyCol(4, "Logical SortDesc") 
return
;--------------------
Fill:
Gui,2: Submit, Nohide
Gui,2:ListView, LV1
ib=0
LV_Delete()
Loop, Files, % vDir1 "\*", D                        ;- folders
{
	if A_LoopFileName in %foldersBlacklist%
	{
		excludedFolders .= """" . A_LoopFileFullPath . """ "
		continue
	}
   ib++	
   SplitPath,A_LoopFileFullPath, name, dir, ext, name_no_ext, drive
   LV_Add("",ib,name,A_LoopFileFullPath,a_loopfiletimemodified)
}
LV_ModifyCol(4, "Logical SortDesc") 
return
;----------------
LV1a:
Gui,2: Submit, Nohide
Loop, 2
	Gui,2:ListView, LV%A_Index%
RC:=LV_GetNext("C")
RF:=LV_GetNext("F")
GC:=LV_GetCount()
  If A_GuiEvent=Doubleclick
     {
     LV_GetText(C1,A_EventInfo,1)
     LV_GetText(C2,A_EventInfo,2)
     LV_GetText(C3,A_EventInfo,3)
     LV_GetText(C4,A_EventInfo,4)
     path := c3
     try
        run,%c3%
     return
     }
return
;==========================
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: Help with Search Box for ListView

09 Jun 2020, 00:59

once again garry
you my hero
thanks alot! :clap:
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: Help with Search Box for ListView

09 Jun 2020, 01:48

i make it without button (for live searching) .

its works fine until you double click on some selected row,
then because the listview is shacking its not working so well.. :(

any better way ?

Code: Select all

;- Help with Search Box for ListView 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=77040

vDir1 = c:
Gui,2:default
Gui 2:Add, Button,gShowAll,ShowAll
Gui 2:Add, Edit, w100 vfind
;Gui 2:Add, Edit, w100 vfind gSearch   ;- or maybe
Gui,2: Add , ListView, r25 w323 backgroundGray cYellow grid vLV1 gLV1a altsubmit Multi, #|%vDir1%|Fullpath|Date
LV_ModifyCol(1,0),LV_ModifyCol(2,200),LV_ModifyCol(3,0),LV_ModifyCol(4,100),LV_ModifyCol(1,"integer"),LV_ModifyCol(2,"left"),LV_ModifyCol(4,"digit"),LV_ModifyCol(4, "left") 
Gui,2: Show
gosub,fill
gosub,Search
return
;---------------------
2Guiclose:
exitapp
esc::exitapp
;---------------------
;----------------------------
Showall:
Guicontrol,2:,Find
Search:
SetTimer, timer, 250

timer:
if find =
	goto, Fill
else
	goto, findit

return

findit:
Gui,2:default
Gui,2:submit,nohide
Gui,2:ListView, LV1
SetKeyDelay,20,20
LV_Delete()
IB=0
GuiControl,2: -Redraw,LV1
Loop, Files, % vDir1 "\*", D                        ;- folders
 {
   ib++	
   SplitPath,A_LoopFileFullPath, name, dir, ext, name_no_ext, drive
   if instr(name,find)
     LV_Add("",ib,name,A_LoopFileFullPath,a_loopfiletimemodified)
 }
GuiControl,2: +Redraw,LV1
LV_ModifyCol(4, "Logical SortDesc") 
return
;--------------------
Fill:
Gui,2: Submit, Nohide
Gui,2:ListView, LV1
ib=0
LV_Delete()
Loop, Files, % vDir1 "\*", D                        ;- folders
{
	if A_LoopFileName in %foldersBlacklist%
	{
		excludedFolders .= """" . A_LoopFileFullPath . """ "
		continue
	}
   ib++	
   SplitPath,A_LoopFileFullPath, name, dir, ext, name_no_ext, drive
   LV_Add("",ib,name,A_LoopFileFullPath,a_loopfiletimemodified)
}
LV_ModifyCol(4, "Logical SortDesc") 
return
;----------------
LV1a:
Gui,2: Submit, Nohide
Loop, 2
	Gui,2:ListView, LV%A_Index%
RC:=LV_GetNext("C")
RF:=LV_GetNext("F")
GC:=LV_GetCount()
  If A_GuiEvent=Doubleclick
     {
     LV_GetText(C1,A_EventInfo,1)
     LV_GetText(C2,A_EventInfo,2)
     LV_GetText(C3,A_EventInfo,3)
     LV_GetText(C4,A_EventInfo,4)
     path := c3
     try
        run,%c3%
     return
     }
return
;==========================

garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: Help with Search Box for ListView

09 Jun 2020, 06:58

When I click 'Documents and settings' or 'System volume information' , I get message > 'Access denied'
I don't see this in explorer C:\ (?)

instead of doubleclick can also use ( one click ) :
If A_GuiEvent=Normal
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: Help with Search Box for ListView

09 Jun 2020, 09:35

now modified ...
EDIT : again modified > if instr(z1,find) > missing brackets { }

Code: Select all

;----
  If A_GuiEvent=Normal
     {
     LV_GetText(C3,A_EventInfo,3)
     if (c3="C:\System Volume Information")
       run,::{20d04fe0-3aea-1069-a2d8-08002b30309d}
     else if ((c3="C:\Documents and settings") or (c3="C:\Dokumente und Einstellungen"))  ;- english and german
       run,C:\users\%a_username%\Documents
     else if (c3="C:\$Recycle.Bin")
       run,::{645ff040-5081-101b-9f08-00aa002f954e}
     else
        run,%c3%
     return
     }
 ;----    
I tried this , had problem when clear searchfield with button , sometimes reads double , removed the clear button

Code: Select all

;- Help with Search Box for ListView 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=77040

#warn
#noenv
setworkingdir,%a_scriptdir%
SetBatchLines, -1
SetKeyDelay,50,50


dir1 = C:
Gui,2:default
Gui,2: -DPIScale
Gui,2:Font,s14 , Verdana
Gui,2:Color,Black,Black
wa:=A_screenwidth,ha:=A_screenHeight,xx:=100,
T1:=(wa*0)/xx,T2:=(wa*25)/xx,T3:=(wa*0)/xx,T4:=(wa*9)/xx  ;- columns-width

x:=(wa*1)/xx,y:=(ha*2)/xx,w:=(wa*6)/xx,h:=(ha*2.7)/xx
  Gui 2:Add, Edit,x%x% y%y% w%w% h%h% vfind cRed gSearch
x:=(wa*1)/xx,y:=(ha*7)/xx,w:=(wa*36)/xx,h:=(ha*80)/xx
  Gui,2: Add , ListView, x%x% y%y% w%w% h%h% backgroundGray cYellow grid vLV1 gLV1a altsubmit Multi, #|%dir1%|Fullpath|Date
  LV_ModifyCol(1,T1),LV_ModifyCol(2,T2),LV_ModifyCol(3,T3),LV_ModifyCol(4,T4),LV_ModifyCol(1,"integer"),LV_ModifyCol(2,"left"),LV_ModifyCol(4,"digit"),LV_ModifyCol(4, "left") 
x:=(wa*2)/xx,y:=(ha*2)/xx,w:=(wa*40)/xx,h:=(ha*90)/xx
  Gui,2: Show,x%x% y%y% w%w% h%h%,LISTVIEW show folders
GuiControl,2: Focus,Find
gosub,fill
return
;---------------------
2Guiclose:
exitapp
;----------------------------

;------------------
Search:
Gui,2:default
Gui,2:Submit, Nohide
if find=
   goto,fill
Gui,2:ListView, LV1
ib=0
row := []
LV_Delete()
loop,files,%dir1%\*,D
{
   ib++	
   z:=A_LoopFileFullPath
   z1:=a_loopfilename
   row := []
   if instr(z1,find)
     {
     row.push(ib,z1,z,a_loopfiletimemodified)
     LV_add("",row*)	
     row := []
     }
}
LV_ModifyCol(4, "Logical SortDesc")
return
;----------------
Fill:
Gui,2:default
Gui,2:Submit, Nohide
Gui,2:ListView, LV1
ib=0
row := []
LV_Delete()
GuiControl,2: -Redraw,LV1
loop,files,%dir1%\*,D
{
   ib++	
   z:=A_LoopFileFullPath
   z1:=a_loopfilename
   row := []
   row.push(ib,z1,z,a_loopfiletimemodified)
   LV_add("",row*)	
   row := []
}
GuiControl,2: +Redraw,LV1
LV_ModifyCol(4, "Logical SortDesc")
sleep,500
GuiControl,2: Focus,Find
return
;----------------
LV1a:
Gui,2: Submit, Nohide
Gui,2:ListView, LV1
RC:=LV_GetNext("C")
RF:=LV_GetNext("F")
GC:=LV_GetCount()
  If A_GuiEvent=Normal
     {
     LV_GetText(C3,A_EventInfo,3)
     if (c3="C:\System Volume Information")
       run,::{20d04fe0-3aea-1069-a2d8-08002b30309d}
     else if ((c3="C:\Documents and settings") or (c3="C:\Dokumente und Einstellungen"))  ;- english and german
       run,C:\users\%a_username%\Documents
     else if (c3="C:\$Recycle.Bin")
       run,::{645ff040-5081-101b-9f08-00aa002f954e}
     else
        run,%c3%
     return
     }
return
;==========================
Last edited by garry on 10 Jun 2020, 05:12, edited 1 time in total.
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: Help with Search Box for ListView

10 Jun 2020, 03:02

garry wrote:
09 Jun 2020, 06:58
When I click 'Documents and settings' or 'System volume information' , I get message > 'Access denied'
I don't see this in explorer C:\ (?)

instead of doubleclick can also use ( one click ) :
If A_GuiEvent=Normal
coz these folders are system folders,
you need to enable it by windows settings to see them

anyway its not my point,
even normal folders wont open coz the listview refreshing non stop while serching is avtice,
iill give a try for one click instead doubleclick
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: Help with Search Box for ListView

10 Jun 2020, 03:03

my final code thanks to garry:
:bravo:

Code: Select all

vDir1 = c:

Gui,2:default
Gui Font, s10, Tahoma
Gui 2:Add, Edit, x22 w340 y11 hWndhEdtValue vfind cRed gSearch
SendMessage 0x1501, 1, "Search",, ahk_id %hEdtValue% ; EM_SETCUEBANNER
Gui,2: Add , ListView, x20 r25 w350 backgroundGray cYellow grid vLV1 gLV1a altsubmit Multi, #|%vDir1%|Fullpath|Date
LV_ModifyCol(1,0),LV_ModifyCol(2,200),LV_ModifyCol(3,0),LV_ModifyCol(4,127),LV_ModifyCol(1,"integer"),LV_ModifyCol(2,"left"),LV_ModifyCol(4,"digit"),LV_ModifyCol(4, "left") 
Gui,2: Add , Button, gOk w350 h25 +Center, ---> Select <---

Gui,2: Show, w390 h610 ,
GuiControl, Focus, find
gosub,fill
return


Search:
Gui,2:default
Gui,2:Submit, Nohide
if find=
   goto,fill
Gui,2:ListView, LV1
ib=0
row := []
LV_Delete()
loop,files,%vdir1%\*,D
{
   ib++	
   z:=A_LoopFileFullPath
   z1:=a_loopfilename
   row := []
   if instr(z1,find)
     row.push(ib,z1,z,a_loopfiletimemodified)
   LV_add("",row*)	
   row := []
}
LV_ModifyCol(4, "Logical SortDesc")
return


Ok:
aa:= LV_GetNext(0, "F")
LV_ClickRow(HLV,aa)
LV_GetText(C3,aa,3)
path := c3
;~ MsgBox % path
if path = Fullpath
	MsgBox 0x182000, , no select
else
	MsgBox % path
return

LV_ClickRow(HLV, Row) { ; just me -> http://www.autohotkey.com/board/topic/86490-click-listview-row/#entry550767
   ; HLV : ListView's HWND, Row : 1-based row number
   VarSetCapacity(RECT, 16, 0)
   SendMessage, 0x100E, Row - 1, &RECT, , ahk_id %HLV% ; LVM_GETITEMRECT
   POINT := NumGet(RECT, 0, "Short") | (NumGet(RECT, 4, "Short") << 16)
   PostMessage, 0x0201, 0, POINT, , ahk_id %HLV% ; WM_LBUTTONDOWN
   PostMessage, 0x0202, 0, POINT, , ahk_id %HLV% ; WM_LBUTTONUP
}
;======================================

Fill:
Gui,2:default
Gui,2:Submit, Nohide
Gui,2:ListView, LV1
ib=0
row := []
LV_Delete()
GuiControl,2: -Redraw,LV1
loop,files,%vdir1%\*,D
{
   ib++	
   z:=A_LoopFileFullPath
   z1:=a_loopfilename
   row := []
   row.push(ib,z1,z,a_loopfiletimemodified)
   LV_add("",row*)	
   row := []
}
GuiControl,2: +Redraw,LV1
LV_ModifyCol(4, "Logical SortDesc")
sleep,500
GuiControl,2: Focus,Find
return
;----------------

LV1a:
Gui,2: Submit, Nohide
Gui,2:ListView, LV1
RC:=LV_GetNext("C")
RF:=LV_GetNext("F")
GC:=LV_GetCount()
  If A_GuiEvent=Doubleclick
     {
     LV_GetText(C1,A_EventInfo,1)
     LV_GetText(C2,A_EventInfo,2)
     LV_GetText(C3,A_EventInfo,3)
     LV_GetText(C4,A_EventInfo,4)
     path := c3
	 MsgBox %path%
     return
     }
return
;======================================================

edit:
sometimes its stiil a little buggy when you search something that not found and remove it,
then the full list not showing again (sometimes half list , sometimes empty list)

i think i manged to fix it with:

Code: Select all

   if instr(z1,find)
{
     row.push(ib,z1,z,a_loopfiletimemodified)
     LV_add("",row*)	
     row := []
}
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: Help with Search Box for ListView  Topic is solved

10 Jun 2020, 05:09

aargh , yes , sorry , missing brackets ' { } '
thanx for the function > EM_SETCUEBANNER

added , close script :

Code: Select all

2Guiclose:
exitapp
and to open folder :

Code: Select all

  If A_GuiEvent=DoubleClick
     {
     LV_GetText(C3,A_EventInfo,3)
     if (c3="C:\System Volume Information")
       run,::{20d04fe0-3aea-1069-a2d8-08002b30309d}
     else if ((c3="C:\Documents and settings") or (c3="C:\Dokumente und Einstellungen"))  ;- english and german
       run,C:\users\%a_username%\Documents
     else if (c3="C:\$Recycle.Bin")
       run,::{645ff040-5081-101b-9f08-00aa002f954e}
     else
        run,%c3%
     return
     }
Button Show Name :

Code: Select all

ShowName:
Gui,2:ListView, LV1
RF:=LV_GetNext("F")
if (rf=0)
  return
LV_GetText(C3,RF,3)
MsgBox,%c3%
return
EDIT : small modified script ( looks like yours ) , added : count folders

Code: Select all

;- Help with Search Box for ListView 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=77040
#warn
#noenv
setworkingdir,%a_scriptdir%
SetBatchLines, -1
SetKeyDelay,50,50
dir1 = C:
Gui,2:default
Gui,2: -DPIScale
Gui,2:Font,s12 ,Tahoma
Gui,2:Color,Black,Black
wa:=A_screenwidth,ha:=A_screenHeight,xx:=100,
T1:=(wa*0)/xx,T2:=(wa*25)/xx,T3:=(wa*0)/xx,T4:=(wa*9)/xx  ;- columns-width

x:=(wa*1)/xx,y:=(ha*1)/xx,w:=(wa*11)/xx,h:=(ha*2.6)/xx
  Gui 2:Add, Edit,x%x% y%y% w%w% h%h% hWndED1 vfind cRed gSearch
   SendMessage 0x1501, 1, "Search",, ahk_id %ED1%               ;- EM_SETCUEBANNER

x:=(wa*13)/xx,y:=(ha*1)/xx,w:=(wa*4)/xx,h:=(ha*2.6)/xx
  Gui 2:Add, Edit,x%x% y%y% w%w% h%h% vTotal1 cYellow right

x:=(wa*1)/xx,y:=(ha*5)/xx,w:=(wa*36)/xx,h:=(ha*75)/xx
  Gui,2: Add , ListView, x%x% y%y% w%w% h%h% backgroundGray cYellow grid vLV1 gLV1a altsubmit , #|%dir1%|Fullpath|Date
  LV_ModifyCol(1,T1),LV_ModifyCol(2,T2),LV_ModifyCol(3,T3),LV_ModifyCol(4,T4),LV_ModifyCol(1,"integer"),LV_ModifyCol(2,"left"),LV_ModifyCol(4,"digit"),LV_ModifyCol(4, "left") 

x:=(wa*15.5)/xx,y:=(ha*84)/xx,w:=(wa*9)/xx,h:=(ha*2.6)/xx
  Gui 2:Add,Button,x%x% y%y% w%w% h%h% gShowName,<ShowName>

x:=(wa*0.1)/xx,y:=(ha*0.1)/xx,w:=(wa*40)/xx,h:=(ha*90)/xx
  Gui,2: Show,x%x% y%y% w%w% h%h%,LISTVIEW show folders
GuiControl,2: Focus,Find
gosub,fill
return
;---------------------
2Guiclose:
exitapp
;----------------------------
ShowName:
Gui,2:ListView, LV1
RF:=LV_GetNext("F")
if (rf=0)
  return
LV_GetText(C3,RF,3)
MsgBox,%c3%
return
;------------------
Search:
Gui,2:default
Gui,2:Submit, Nohide
if find=
   goto,fill
Gui,2:ListView, LV1
ib=0
row := []
LV_Delete()
loop,files,%dir1%\*,D
{
   z:=A_LoopFileFullPath
   z1:=a_loopfilename
   row := []
   if instr(z1,find)
     {
     iB++
     row := []
     row.push(ib,z1,z,a_loopfiletimemodified)
     LV_add("",row*)	
     row := []
     }
}
LV_ModifyCol(4, "Logical SortDesc")
GuiControl,2:,Total1,%ib%
return
;----------------
Fill:
Gui,2:default
Gui,2:Submit, Nohide
Gui,2:ListView, LV1
ib=0
row := []
LV_Delete()
GuiControl,2: -Redraw,LV1
loop,files,%dir1%\*,D
{
   ib++	
   z:=A_LoopFileFullPath
   z1:=a_loopfilename
   row := []
   row.push(ib,z1,z,a_loopfiletimemodified)
   LV_add("",row*)	
   row := []
}
GuiControl,2: +Redraw,LV1
LV_ModifyCol(4, "Logical SortDesc")
GuiControl,2:,Total1,%ib%
sleep,500
GuiControl,2: Focus,Find
return
;----------------
LV1a:
Gui,2: Submit, Nohide
Gui,2:ListView, LV1
RC:=LV_GetNext("C")
RF:=LV_GetNext("F")
GC:=LV_GetCount()
  If A_GuiEvent=Doubleclick
     {
     LV_GetText(C3,A_EventInfo,3)
     if (c3="C:\System Volume Information")
       run,::{20d04fe0-3aea-1069-a2d8-08002b30309d}
     else if ((c3="C:\Documents and settings") or (c3="C:\Dokumente und Einstellungen"))  ;- english and german
       run,C:\users\%a_username%\Documents
     else if (c3="C:\$Recycle.Bin")
       run,::{645ff040-5081-101b-9f08-00aa002f954e}
     else
        run,%c3%
     return
     }
return
;==========================
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: Help with Search Box for ListView

11 Jun 2020, 02:31

Thanks for the count folders,
and the Button code more simple now than just me's function
:bravo:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 132 guests