Search files with searchMyFiles tool
![]()
SearchMyFiles is a free nirSoft advanced Application for searching in files (site:https://www.nirsoft.net/utils/search_my_files.html). in my think; its better than windows explorer.can run with windows32 or 64 bits and with command lines also. i made a personal challenge to make this app running from vfp. i built a top level form gathering a majority of command lines options.these can be modified interactively for making a new search. there is nearly 38 options used in this vfp application.(original app have near 50 parameters).majority of params are 0|1 values. running this form, built a tabbed txt file whose is appended in a vfp cursor.(the txt file is mandatory converted from unicode to double bits by strconv() function supported by vfp9.(otherwise no data in vfp because vfp is not unicode). a second cursor (with select statement) cleans the first for retaining only interesting fields. the modified options are in the second column of grid (read the info for each parameter.can modify it(there is a contextuel menu in each column.text1) Click on option "folder " to fire a dialog to select a folder. click or rightclick on xval column to fire a contextuel menu. the search result is built in another form with a vfp grid. this grid have the columns retained above and looks like to be a windows listView. the grid builds also the extracted icons in first column: first icon from the filename associated application or from shell32.dll if associated app not found) the dynamicBackcolor builds these png images. to do: attach specific icon for each file (prg,form,report,...) .this can replace the associated application icon.. each row have a ontextuel menu to ( edit file,browse folder,run with associated app,properties,record fields) the form have also a contextuel menu (options selected,statistics,grildlines(0-1-2-3),fontsize,search any word,export to html(vert-hor),original help,vfp help) of course can print html reports in their specific contextuel menu... these menus are fired with bindevent function. Fields shown are: -filename,folder,size (in unit set initially),modified dateTime,Created dateTime,Last accessed DateTime,Attribute,Extension,Short filename,FileOwner,Size on Disk). in grid each header can be order ascending or descending by simple click on (inde are built on character expressions). Closing the second form and modifying the options in first form can re run the app easily to obtain results searched.the first main form is then reusable for many searches by the user. Running the app and learning well the options can perform any search files with very advanced parameters. -for file edit (procedure yedit): ctrl+f to fire dialog search-f3 to continue search-esc to close window opened).vfp edit files as text (even pictures,..) warning: if the search traverse big folders it needs a time to achieve (as windows explorer does also)-(1 to many minutes).the ellapsed time is in statistics menu option. note: if there is no files in grid sure thre is an error in the command line.review your settings in the first form. for redistribution read licence in the author site. the zip contains the project with complet files and exe compiled with vfp9sp2. files running with this prg: ysearch.prg,searchmyfiles.exe,searchmyfiles.chm,find.ico. [post 254]
Click on code to select [then copy] -click outside to deselect
*1* created on tuesday 16 of january 2018
*save this file as ysearch.prg
if !_vfp.startmode=0
on shutdown quit
endi
clea all
close data all
set safe off
set talk off
clea resources
clea dlls
set date short
publi m.yrep
m.yrep=addbs(justpath(sys(16,1)))
set defa to (yrep)
if !file("SearchMyFiles.exe")
messagebox("SearchMyFiles.exe must be in source folder mandatory to run this application!",16+4096,"Error",4000)
retur .f.
endi
PUBLIC oymain
oymain=NEWOBJECT("ymain")
oymain.Show
read events
RETURN
*oymain
*
DEFINE CLASS ymain AS form
ShowWindow=2
BorderStyle = 0
Height = 658
Width = 950
ShowTips = .T.
AutoCenter = .T.
icon="find.ico"
Caption = " Options settings- column2(xVAL) modifiable - can re run the form."
Name = "ymain"
ADD OBJECT grid1 AS grid WITH ;
Anchor = 15, ;
Height = 620, ;
Left = 1, ;
Top = 0, ;
Visible = .F., ;
Width = 950, ;
Name = "Grid1"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 627, ;
Left = 16, ;
Height = 25, ;
Width = 97, ;
FontBold = .T., ;
FontSize = 11, ;
Anchor = 768, ;
Caption = "Run", ;
MousePointer = 15, ;
SpecialEffect = 2, ;
ForeColor = RGB(255,255,0), ;
BackColor = RGB(128,0,64), ;
Name = "Command1"
ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
FontSize = 8, ;
Caption = "", ;
Height = 16, ;
Left = 151, ;
Top = 630, ;
Width = 2, ;
ForeColor = RGB(255,0,0), ;
Name = "Label1"
ADD OBJECT image1 AS image WITH ;
Stretch = 2, ;
Height = 20, ;
Left = 118, ;
Top = 629, ;
Width = 20, ;
Name = "Image1"
ADD OBJECT timer1 as Timer with ;
interval=5000,;
enabled=.f.
name="timer1"
Procedure timer1.timer
thisform.label1.caption="Time ellapsed="+trans(seconds()-_screen.t0,"99999")+" seconds"
endproc
PROCEDURE ybuild
if !used("ycurs0") &&preserve cursor for re use and modify
create cursor ycurs0 (option c(30),xval c(100),info c(250))
set memow to 8192
local m.myvar
text to m.myvar pretext 7 textmerge noshow
FilesWildcard,*,Specifies the files wildcard.
SubfoldersWildcard,*, Specifies the files wildcard.
BaseFolder,"D:\________ytest2017",click to fire dialog...Specifies the base folders to search. can use many folder (comma separated)
ScanSubfolders,1, Specifies whether to search in subfolders. 1 = Yes 0 = No.
FindFiles,1,Specifies whether to find files. 1 = Yes, 0 = No.
FindFolders,0,Specifies whether to find folders. 1 = Yes 0 = No.
UseFileSizeAtLeast,0,Specifies whether to use the "At Least" and "At Most" file size filter. 1 = Yes 0 = No.
UseFileSizeAtMost,0,Specifies whether to use the "At Least" and "At Most" file size filter. 1 = Yes 0 = No.
FileSizeAtLeast,0,Specifies the values of file size filters.
FileSizeAtMost,0,Specifies the values of file size filters.
FileSizeAtLeastUnit,1,Specifies the units of file size filters. 1 = Bytes 2 = KB 3 = MB 4 = GB
FileSizeAtMostUnit,1, Specifies the units of file size filters. 1 = Bytes 2 = KB 3 = MB 4 = GB
FileAttrReadOnly,1,Specifies the file attributes filter. 1 = Both 2 = No 3 = Yes.
FileAttrSystem,1,Specifies the file attributes filter. 1 = Both 2 = No 3 = Yes.
FileAttrHidden,1,Specifies the file attributes filter. 1 = Both 2 = No 3 = Yes.
FileAttrArchive,1,Specifies the file attributes filter. 1 = Both 2 = No 3 = Yes.
FileAttrCompressed,1,Specifies the file attributes filter. 1 = Both 2 = No 3 = Yes.
FileAttrEncrypted,1,Specifies the file attributes filter. 1 = Both 2 = No 3 = Yes.
FileContains,0,Specifies the 'File Contains' option. 0 = None 1 = Text 2 = Binary (if text specified this value=1)
FileContainsText, ,Specifies the File Contains text (to specify if the case).
FileContainsCaseSensitive,0,Specifies whether the 'File Contains' string is case sensitive. 1 = Yes 0 = No.
FileTimeCreated,0, Specifies the filter option by file time. 0 = All Times 1 = Time Range 2 = Last XX Seconds 3 = Last XX Minutes 4 = Last XX Hours 5 = Last XX Days.
FileTimeModified,0,Specifies the filter option by file time. 0 = All Times 1 = Time Range 2 = Last XX Seconds 3 = Last XX Minutes 4 = Last XX Hours 5 = Last XX Days.
FileTimeAccessed,0,Specifies the filter option by file time. 0 = All Times 1 = Time Range 2 = Last XX Seconds 3 = Last XX Minutes 4 = Last XX Hours 5 = Last XX Days.
FileTimeCreatedLastXX,1,Specifies the last xx seconds/minutes/hours/days values.
FileTimeModifiedLastXX,1,Specifies the last xx seconds/minutes/hours/days values.
FileTimeAccessedLastXX,1,Specifies the last xx seconds/minutes/hours/days values.
Searchmode,1,Specifies the search mode. 1 = Standard Search 2 = Duplicate Search.
UseMaxNumOfFiles,1,Specifies whether to limit the number of files to find. 1 = Yes 0 = No.
MaxNumOfFiles,15000,Specifies the maximum number of files to find
SubFolderDepth,0,Specifies the subfolders depth. 0 = Unlimited.
FileTimeAccessed1,<<DATETIME( )>>,Specifies date/time range values. The date/time value must be in the following format: dd-mm-yyyy hh:nn:ss
FileTimeAccessed2,<<dateTime()>>, Specifies date/time range values. The date/time value must be in the following format: dd-mm-yyyy hh:nn:ss
FileTimeModified1,<<DATETIME()>>, Specifies date/time range values. The date/time value must be in the following format: dd-mm-yyyy hh:nn:ss
FileTimeModified2,<<dateTime()>>, Specifies date/time range values. The date/time value must be in the following format: dd-mm-yyyy hh:nn:ss
FileTimeCreated1 ,<<DATETIME()>>, Specifies date/time range values. The date/time value must be in the following format: dd-mm-yyyy hh:nn:ss
FileTimeCreated2 ,<<dateTime()>>, Specifies date/time range values. The date/time value must be in the following format: dd-mm-yyyy hh:nn:ss
DontSaveMRULists,1,Don't save MRU list
endtext
local m.x1,m.x2,m.x3
for i=1 to memlines(m.myvar)
m.x1=getwordnum(mline(m.myvar,i),1,",")
m.x2=getwordnum(mline(m.myvar,i),2,",")
m.x3=getwordnum(mline(m.myvar,i),3,",")
insert into ycurs0 values(m.x1,m.x2,m.x3)
endfor
*brow
endi
sele ycurs0
locate
with _screen
.addProperty("t0",seconds())
.addproperty("Ellapsed",0)
locate for option="FileSizeAtLeastUnit" &&units 1 buytes,2 kbytes ,3 mbytes, 4 Gbytes
if found()
_screen.addProperty("xunit",allt(xval))
else
_screen.addProperty("xunit","1") &&bytes
endi
endwith
with thisform.grid1
.recordsource="ycurs0"
.recordsourcetype=1
.gridlines=3
.deletemark=.f.
.fontbold=.t.
.fontsize=11
.column1.width=220
.column1.readonly=.t.
.column2.width=150
.column2.fontsize=10
.column3.width=.width-.column1.width-.column2.width
.column3.fontsize=8
.column3.fontbold=.t.
.column3.readonly=.t.
.column1.text1.mousepointer=15
.column1.text1.tooltiptext=iif(recno()=3,"Click to fire directories dialog","")
.column3.dynamicForecolor="rgb(0,0,255)"
.column1.dynamicbackcolor="iif(recno()=3,rgb(0,255,0),rgb(255,255,217))"
bindevent(.column2.text1,"rightclick",thisform,"my")
bindevent(.column2.text1,"click",thisform,"my0")
bindevent(.column1.text1,"mousedown",thisform,"ydir")
locate
.setfocus
.visible=.t.
endwith
*can test other options in searchMyfiles.cfg (open it as txt file)
ENDPROC
PROCEDURE YDIR
Lparameters nButton, nShift, nXCoord, nYCoord
*--- aevent create an array laEvents
Aevents( myArray, 0)
*--- reference the calling object
loObject = myArray[1]
sele ycurs0
if allt(lower(option))=="basefolder"
local m.x
m.x=getdir("c:\","","",32)
if empty( m.x)
return.f.
endi
repl xval with '"'+allt(m.x)+'"'
thisform.grid1.refresh
endi
endproc
PROCEDURE my0
KEYBOARD "{CTRL+A}"
ENDPROC
PROCEDURE my
Lparameters nButton, nShift, nXCoord, nYCoord
*--- aevent create an array laEvents
Aevents( myArray, 0)
*--- reference the calling object
loObject = myArray[1]
keyboard"{CTRL+A}"
DEFINE POPUP raccourci SHORTCUT RELATIVE FROM MROW(),MCOL()
DEFINE BAR _med_redo OF raccourci PROMPT "\<Rétablir" ;
KEY CTRL+R, "Ctrl+R" ;
MESSAGE "Rétablit la dernière opération annulée"
DEFINE BAR _med_undo OF raccourci PROMPT "\<Annuler" ;
KEY CTRL+Z, "Ctrl+Z" ;
MESSAGE "Annule la dernière modification"
DEFINE BAR _med_slcta OF raccourci PROMPT "Sélec\<tionner tout" ;
KEY CTRL+A, "Ctrl+A" ;
MESSAGE "Sélectionne tout le texte ou tous les éléments de la fenêtre active"
DEFINE BAR _med_copy OF raccourci PROMPT "Co\<pier" ;
KEY CTRL+C, "Ctrl+C" ;
MESSAGE "Copie la sélection et la place dans le Presse-papiers"
DEFINE BAR _med_paste OF raccourci PROMPT "C\<oller" ;
KEY CTRL+V, "Ctrl+V" ;
MESSAGE "Place le contenu du Presse-papiers au point d'insertion"
ACTIVATE POPUP raccourci
ENDPROC
PROCEDURE Load
_screen.visible=.t.
_screen.windowstate=1
ENDPROC
PROCEDURE Init
if directory(m.yrep+"icons")
dele file (m.yrep+icons\*.*")
else
md (m.yrep+"icons")
endi
thisform.ybuild()
ENDPROC
PROCEDURE Destroy
clea resources
try
erase (m.yrep+"icons\*.*)
rd (m.yrep+"icons")
catch
endtry
m.yrep=null
release m.yrep
oymain=null
release oymain
clea events
ENDPROC
PROCEDURE Activate
thisform.label1.caption=""
ENDPROC
PROCEDURE command1.Click
with thisform
.label1.caption="Time ellapsed..."
.image1.visible=.t.
.timer1.enabled=.t.
.ybuild()
endwith
local m.youtput
m.youtput=m.yrep+"ysearch_"+strtran(time(),":","_")+".txt"
local m.myvar
m.myvar="SearchMyFiles.exe /stab "+ m.youtput+chr(13)
m.myvar=m.myvar+"/nosort"+chr(13)
sele ycurs0
scan
m.myvar=m.myvar+"/"+allt(option)+" "+allt(xval)+chr(13)
endscan
m.myvar=strtran(m.myvar,chr(13),spac(4))
strtofile(m.myvar ,"ybat.bat")
local oShell
oShell = CreateObject("WScript.Shell")
oShell.Run("ybat.bat", 0, .t.) &&wait until terminates better than shellexecute API
oshell=null
thisform.label1.caption=m.youtput+ " created"
strtofile( strconv(filetostr(m.youtput),6) ,m.yrep+"ysearch.txt") &&convert unicode to double bits to text supported by vfp9.(otherwise no data in vfp)
inke(2)
**************************************
do yprocess with (m.yrep+"ysearch.txt")
**************************************
END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c2EcDgFAYIuaXS3bbOh6MIC5IAP5Eh5fk2exC4tpgwZyiyFgvhEMBBEAIfkEBQUAAAAsAAACAA4AHQAABHMQyAnYoViSlFDGXBJ808Ep5KRwV8qEg+pRCOeoioKMwJK0Ekcu54h9AoghKgXIMZgAApQZcCCu2Ax2O6NUud2pmJcyHA4L0uDM/ljYDCnGfGakJQE5YH0wUBYBAUYfBIFkHwaBgxkDgX5lgXpHAXcpBIsRADs=
endtext
this.pictureval=strconv(m.myvar0,14) &&animated gif
this.visible=.f.
ENDPROC
ENDDEFINE
*-- EndDefine: ymain
PROCEDURE yprocess
lparameters youtput
if pcount()<>1
return .f.
endi
*using the mySearchfiles output (by command line) as txt delimited with TAb in a vpf cursor
if used("zcurs")
use in select("zcurs")
endi
create cursor ycurs ( filename c(70),folder c(180),Size c(10),ModifTime c(20),CreatTime c(20),;
LastAcTime c(20),EntmodTime c(20),Attr c(6),Ext c(5),DuplNumber c(5),;
DuplicGrp c(5),FilePos c(5),FilContent c(50),ShortFilen c(50),FileOwner c(40),SizeOnDisk c(10) )
appe from (youtput) delimited with TAB
*make yicon at first column in cursor
sele ycurs
local m.x
m.x=""
for i=1 to fcount()
if inlist(i,7,10,11,12,13) &&select only fields wanted here
loop
endi
if !i=fcount()
m.x=m.x+field(i)+","
else
m.x=m.x+field(i)
endi
endfor
m.x="yicon"+","+m.x
sele ycurs
Alter table ycurs add column yicon c(100)
local m.myvar
text to m.myvar textmerge noshow
sele <<m.x>> from ycurs into cursor zcurs readwrite
endtext
execscript(m.myvar)
locate
erase (m.yrep+"ysearch.txt")
if used("ycurs")
use in select("ycurs")
endi
sele zcurs
publi oform1
oform1=NEWOBJECT("yResults")
_screen.windowstate=2
oform1.Show (1) &&modal (bloque the main form oymain to release until its released)
endproc
DEFINE CLASS yResults AS form
Height = 700
Width = 1054
ShowWindow =0
windowstate=2
ShowTips = .T.
AutoCenter = .T.
icon="find.ico"
Caption = "Search from criteria "
Name = "Form1"
ADD OBJECT grid1 AS grid WITH ;
Anchor = 15, ;
recordsource="zcurs", ;
recordsourcetype=1, ;
FontName = "MS Sans Serif", ;
Fontsize=8, ;
DeleteMark = .F., ;
Height = 660, ;
Left = 0, ;
Top = 40, ;
Width = 1056, ;
highLightStyle=0,;
scrollbars=3,;
Name = "Grid1"
ADD OBJECT command1 AS commandbutton with ;
Top = 3,;
Left = 200,;
Height = 27,;
Width = 108, ;
Caption = "M E N U ",;
forecolor=rgb(128,0,64),;
MousePointer = 15,;
SpecialEffect = 2,;
Name = "Command1"
procedure yhelp()
text to m.myvar pretext 7 noshow
SearchMyFiles is a free nirSoft Application for searching in files (https://www.nirsoft.net/utils/search_my_files.html).
in my think; its better than windows explorer.can run with windows32 or 64 bits and with command lines also.
i made a challenge to make this app running from vfp with some cosmetics.
i built a top level form gathering a majority of command lines options.these can be modified interactively for making a new searh.
there is nearly 38 options used in this vfp application.(original app have near 50 parameters).majority of params are 0|1 values.
running this form, built a tabbed txt file whose is appended in a cursor.(the txt file is mandatory converted from unicode to double
bits supported by vfp9.(otherwise no data in vfp).
a second cursor cleans the first for retaining only interesting fields.
the modified options are in the second column of grid (read the info for each parameter.can modify it(there is a contextuel menu in each column.text1)
Click on option "folder " to fire a dialog to select a folder. click or rightclick on xval column to fire contextuel menu.
the search result is built in another form with a vfp grid.
this grid have the columns retained above.
the grid builds also the extracted icons in first column: first icon from the filename associated application or from shell32.dll if associated app not found)
the dynamicBackcolor build these png images.
each row have a ontextuel menu to ( edit file,browse folder,run with associated app,properties,record fields)
the form have also a contextuel menu (options selected,statistics,grildlines(0-1-2-3),fontsize,search any word,export to html(vert-hor),original help,vfp help)
of course can print html reports in their specific contextuel menu...
Fields shown are:
-filename,folder,size (in unit set initially),modified dateTime,Created dateTime,Last accessed DateTime,Attribute,Extension,Short filename,FileOwner,Size on Disk).
in grid each header can be order ascending or descending by simple click on (inde are on character expressions).
Closing the second form and modifying the options in first form can re run the app easily to obtain results searched.
Running the app and learning well the options can perform any search files.
file edit: ctrl+f to fire dialog search-f3 to continue search-esc to close window opened).
warning: if the search traverse big folders it needs a time to achieve (as windows explorer does also)-(1 to many minutes).
for redistribution read licence in the author site.
endtext
local oshell
oshell = Newobject('WScript.Shell')
oshell.Popup(m.myvar,0, ' Summary help', 0+32+4096)
oshell=null
endproc
PROCEDURE yedit
&&rightlick on file name in grid
*--- aevent create an array laEvents
Aevents( myArray, 0)
*--- reference the calling object
loObject = myArray[1]
if ! messagebox("Want to Edit :"+allt(loObject.value)+" ?",4+64)=6
return.f.
endi
sele zcurs
local m.xfilename
m.xfilename=addbs(allt(folder))+allt(filename)
local m.ext
m.ext=justext(filename)
Do Case
Case Inlist(ext,"prg","qpr","mpr","h ")
Modi Comm (m.xfilename) Nowait
Case Inlist(ext,"txt","log","lst","ini"," ")
Modi File (m.xfilename) Nowait
Case Inlist(ext, "pjx","pjt")
Modi Proj (m.xfilename) Nowait
Case Inlist(ext, "frx","frt","lbx","lbt")
Modi Repo (m.xfilename) Nowait
Case Inlist(ext, "scx","sct")
Modi Form (m.xfilename) Nowait
Case Inlist(ext, "mnx","mnt")
Modi Menu (m.xfilename) Nowait
Case Inlist(ext, "qpr")
Modi Query (m.xfilename) Nowait
Case Inlist(ext, "dbc","dct")
Modi Database (m.xfilename) Nowait
Case Inlist(ext, "vcx","vct")
Do (_Browser) With (m.xfilename)
Other
try && if access file not permitted (for ex fxp file in use)
Modi File (m.xfilename) Nowait
catch
wait window "cannot edit the file...no access !" timeout 1
endtry
Endcase
ENDPROC
PROCEDURE myg1
Lparameters nButton, nShift, nXCoord, nYCoord
*--- aevent create an array laEvents
Aevents( myArray, 0)
*--- reference the calling object
loObject = myArray[1]
Local N
N=Int(Val(Substr(loObject.Parent.Name,7)))
Thisform.grid_reorder(N)
Nodefault
ENDPROC
PROCEDURE grid_reorder
* grid_reorder
Lparameters ColNo
Local _sele
_sele=Sele()
If Used("zcurs")
Sele zcurs
If Tagno()=ColNo And !"DESCE"$Set("order")
Set Order To ColNo Desc
Else
Set Order To ColNo Asce
Endif
This.grid1.Refresh
Endif
Sele (_sele)
ENDPROC
PROCEDURE Load
DECLARE INTEGER GetShortPathName IN kernel32;
STRING lpszLongPath,;
STRING @ lpszShortPath,;
INTEGER cchBuffer
&&shellexecute
DECLARE INTEGER ShellExecute IN SHELL32.DLL INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
DECLARE Long ExtractAssociatedIcon IN shell32.dll Long, String, Long @
DECLARE Long DestroyIcon IN user32.dll Long
DECLARE Long GdipCreateBitmapFromHICON IN Gdiplus.dll Long, Long @
DECLARE Long GdipSaveImageToFile IN Gdiplus.dll Long, String, String, String
DECLARE Long GdipDisposeImage IN Gdiplus.dll Long
DECLARE integer FindExecutable IN Shell32.dll ;
string lpFile, ;
string lpDirectory, ;
string @lpResult
ENDPROC
PROCEDURE Destroy
use in select("zcurs")
clea resources
erase ysearch_*.txt
erase ybat*bat &&ybat.bat,ybat1.bat
try
erase (m.yrep+"icons\*.*)
rd (m.yrep+"icons")
catch
endtry
with oymain
.activate
.windowstate=0
endwith
_screen.windowstate=1
oform1=null
release oform1
ENDPROC
procedure init
with oymain
.timer1.enabled=.f.
.image1.visible=.f.
endwith
thisform.caption=thisform.caption+" -"+trans(reccount())+" objects found."
endproc
PROCEDURE grid1.Init
this.scrollbars=3
this.setall("fontbold",.t.,"header")
this.setall("fontsize",10,"header")
if !used("zcurs")
messagebox("no source to continue!",4+4096,"Error",1200)
return .f.
endi
If Reccount("zcurs")>0
dx=Dbf("zcurs")
dx=Left(dx, Rat(".",dx))+"cdx"
for i=1 to fcount()
text to m.myvar textmerge noshow
Inde On <<field(i)>> Tag <<field(i)>> Of (dx)
endtext
=Execscript(m.myvar) &&inde on all fields characters
endfor
Set Orde To 1 Asce &&filename
endi
With Thisform.grid1
.recordsource=""
.recordsource="zcurs"
.recordsourcetype=1
.readonly=.t.
.gridlines=0
.RowHeight = 20
.HeaderHeight=32
For i=1 To .ColumnCount
Bindevent(.Columns(i).header1,"mousedown",Thisform,"myg1") && sorting asc/descending
Endfor
Sele zcurs
Locate
.Refresh
thisform.yFicons() &&place assoctiated icon
for i=2 to .columncount
bindevent(.columns(i).text1,"rightclick",thisform,"ycontext") &&rightclick on filename
endfor
Endwith
ENDPROC
procedure ycontext
&&rightlick on file name in grid
*--- aevent create an array laEvents
Aevents( myArray, 0)
*--- reference the calling object
loObject = myArray[1]
DEFINE POPUP raccourci SHORTCUT RELATIVE FROM MROW(),MCOL()
DEFINE BAR 1 OF raccourci PROMPT "Edit selected file"
DEFINE BAR 2 OF raccourci PROMPT "open selected folder"
DEFINE BAR 3 OF raccourci PROMPT "Run with associated app"
DEFINE BAR 4 OF raccourci PROMPT "Copy"
DEFINE BAR 5 OF raccourci PROMPT "properties"
DEFINE BAR 6 OF raccourci PROMPT "Record Fields"
On selection Bar 1 of raccourci _screen.activeform.yedit()
On selection Bar 2 of raccourci _screen.activeform.yopenfolder()
On selection Bar 3 of raccourci _screen.activeform.yopenAss()
On selection Bar 4 of raccourci _cliptext=allt(loObject.value)
On selection Bar 5 of raccourci ydetailOf(addbs(allt(folder))+allt(filename))
On selection Bar 6 of raccourci _screen.activeform.yprop()
ACTIVATE POPUP raccourci
endproc
Procedure yprop
sele zcurs
local m.x
m.x="Properties "+chr(13)+chr(13)
for i=1 to fcount()
m.x=m.x+field(i)+" :"+eval(field(i))+chr(13)
endfor
messagebox(m.x,0+32+4096,"Record properties")
endproc
procedure yopenAss()
if !used("zcurs")
return .f.
endi
if ! messagebox("Open this file with associated app?",4+64)=6
return .f.
endi
local m.xfilename
m.xfilename=addbs(allt(folder))+allt(filename)
result = ShellExecute(0, "open",m.xfilename,"","",1)
if result<=32
messagebox("An error was occured!",4+4096,'Error',1300)
endi
endproc
Procedure command1.click
DEFINE POPUP raccourci SHORTCUT RELATIVE FROM MROW(),MCOL()
DEFINE BAR 1 OF raccourci PROMPT "1. Executed options"
DEFINE BAR 2 OF raccourci PROMPT "4. execution Statistics"
DEFINE BAR 3 OF raccourci PROMPT "5. Gridlines(cycle 0-1-2-3)"
DEFINE BAR 4 OF raccourci PROMPT "6. Selected File properties"
DEFINE BAR 5 OF raccourci PROMPT "7. Grid fontsize"
DEFINE BAR 6 OF raccourci PROMPT "8. Search any word in grid"
DEFINE BAR 7 OF raccourci PROMPT "9. Export search to html"
DEFINE BAR 8 OF raccourci PROMPT "10. SearchMyFiles original help"
DEFINE BAR 9 OF raccourci PROMPT "11. This vfp app Help"
on selection bar 1 of raccourci _screen.activeform.yoptions()
on selection bar 2 of raccourci _screen.activeform.ystats()
on selection bar 3 of raccourci _screen.activeform.ygridlines()
on selection bar 4 of raccourci ydetailOf(addbs(allt(folder))+allt(filename))
on selection bar 5 of raccourci _screen.activeform.yfsize()
on selection bar 6 of raccourci _screen.activeform.ygridsearch()
on selection bar 7 of raccourci _screen.activeform.yRhtml()
on selection bar 8 of raccourci _screen.activeform.yHelpOr()
on selection bar 9 of raccourci _screen.activeform.yHelp()
ACTIVATE POPUP raccourci
endproc
procedure yHelpOr
if file(m.yrep+"SearchMyFiles.chm")
local m.oo
m.oo=m.yrep+"SearchMyFiles.chm"
run/n explorer &oo
endi
endproc
procedure yRhtml
if file("yhtmlReport.html")
erase "yhtmlReport.html"
endi
local m.rr
m.rr=inputbox("Export to html file : 0 vertical -1 Horizontal","","0")
if empty(m.rr)
return .f.
endi
if !inlist(m.rr,"0","1")
m.rr="0"
endi
set memow to 8192
local m.x
if m.rr="0"
m.x="SearchMyFiles.exe /shtml yhtmlReport.html" +chr(13)
else
m.x="SearchMyFiles.exe /sverhtml yhtmlReport.html" +chr(13)
endi
if file("ybat.bat")
local m.myvar
m.myvar=filetostr("ybat.bat")
m.myvar=strtran(m.myvar,spac(4),chr(13)+chr(10))
else
messagebox("ybat must exist",16+4096,'',2000)
return .f.
endi
for i=2 to memlines(m.myvar)
m.x=m.x+mline(m.myvar,i)+chr(13)
endfor
m.x=strtran(m.x,chr(13),spac(3))
strtofile(m.x,"ybat1.bat")
local oShell
oShell = CreateObject("WScript.Shell")
oShell.Run("ybat1.bat", 0, .t.)
oShell=null
if file(m.yrep+"yhtmlReport.html")
declare integer BringWindowToTop in user32 integer HWND
local apie
apie=newObject("internetexplorer.application")
with apie
.navigate(m.yrep+"yhtmlReport.html")
.menubar=0
.toolbar=0
.statusbar=0
.width=900
.height=600
.top=(sysmetric(2)-.height)/2
.left=(sysmetric(1)-.width)/2
bringWindowToTop(.hwnd)
.visible=.t.
endwith
else
messagebox("yhtmlReport.html not ready !")
endi
*/shtml <Filename> Search and save the result into HTML file (Horizontal).
*/sverhtml <Filename> Search and save the result into HTML file (Vertical).
endproc
procedure yremovesearch()
try
thisform.grid1.setall("dynamicbackcolor","","column")
thisform.grid1.refresh
thisform.removeobject("ygsearch")
catch
endtry
endproc
procedure ygridsearch()
with thisform
try
.addObject("ygsearch","ygsearch")
catch
endtry
with .ygsearch
.left=thisform.command1.left+thisform.command1.width+10
.top=10
.visible=.t.
.text1.setfocus
endwith
endwith
endproc
procedure yopenfolder()
local m.oo
m.oo= allt(zcurs.folder)
if directory(m.oo)
run/n explorer &oo
endi
endproc
procedure ystats()
sele zcurs
LOCAL m.xx,m.xunit
sum int(val(size)) to m.xx &&bytes
do case
case _screen.xunit= "1" &&Specifies the units of file size filters. 1 = Bytes, 2 = KB, 3 = MB, 4 =GB &&fields size & sizeonDisk are in bytes !
m.xunit=" Bytes"
m.xx=m.xx
case _screen.xunit="2"
m.xunit=" kBytes"
m.xx=m.xx/1024
case _screen.xunit="3"
m.xunit=" MBytes"
m.xx=m.xx/(1024*1024)
case _screen.xunit="4"
m.xunit=" GBytes"
m.xx=m.xx/(1024*1024*1024)
endcase
local m.myvar
text to m.myvar textmerge pretext 7 noshow
-Time ellapsed to search=<<trans(_screen.ellapsed,"99999")>> seconds
-records found with options =<<reccount()>>
-Amount capacity of found files=<<m.xx>> <<m.xunit>>
endtext
messagebox(m.myvar,0+32+4096,"Statistics")
endproc
procedure yoptions
local m.ystr
m.ystr=" Options selectected to run SearchMyFiles"+chr(13)+chr(13)
m.ystr=m.ystr+strtran(filetostr("ybat.bat"),spac(4),chr(13))
_cliptext=m.ystr
local oshell
oShell = Createobject('WScript.Shell')
oShell.Popup(m.ystr,0, 'Options selected -in clipboard-', 0+32+4096)
oshell=null
endproc
procedure ygridlines
try
thisform.grid1.gridlines=thisform.grid1.gridlines+1
catch
thisform.grid1.gridlines=0
endtry
endproc
procedure yfsize()
local m.x
m.x=int(val(inputbox("Fontsize to set","",trans(thisform.grid1.fontsize+1))) )
if m.x>=8
with thisform.grid1
for i=2 to .columncount
.columns(i).fontsize=m.x
endfor
.refresh
endwith
endi
endproc
procedure yFicons
Local m.lcIconPath
m.lcIconPath=Addbs(m.yrep+"icons")
Local m.lcresult,m.lcPath,m.lnsuccess,m.lcBmpFile
Sele zcurs
*order on yicon here
set order to filename
Scan
m.lcResult = Space(150)
m.lcPath = Allt(folder)
m.lnSuccess = FindExecutable(Allt(filename),lcPath,@lcResult)
If m.lnSuccess <= 32 &&insuccess
m.lcResult=getenv("windir")+"\system32\shell32.dll" &&insuccessful
Else
&&successfull
Endif
if file(m.lcresult)
m.lcBmpFile =m.lcIconPath+Juststem(m.lcResult)+".png" && path and name of BMP file in which to save the image icon
endi
Repl yicon With (m.lcBmpFile)
If ! file(yicon) &&! File(m.lcBmpFile)
lpiIcon = 0
HICON = ExtractAssociatedIcon (0, m.lcResult, @ lpiIcon)
Bitmap = 0
If GdipCreateBitmapFromHICON (HICON, @ Bitmap) = 0
lqBMP =0h06F47C55041AD3119A730000F81EF32E &&PNG 0h00F47C55041AD3119A730000F81EF32E &&BMP
GdipSaveImageToFile (Bitmap, Strconv (m.lcBmpFile + Chr (0), 5), lqBMP, Null)
GdipDisposeImage (Bitmap)
Else
* = Messagebox ("error")
Endif
DestroyIcon (HICON)
Endi
Endscan
oymain.image1.visible=.f.
oymain.label1.caption="Time ellapsed="+trans(seconds()-_screen.t0,"99999")+" seconds"
*show associated icons of filename
locate
Local loColumn
loColumn = Thisform.grid1.Columns(1)
With loColumn
If !Vartype(.myImage)="O"
.AddObject('myImage','Image')
Endi
.CurrentControl = 'myImage'
.Sparse = .F.
.myImage.Visible = .T.
.myImage.Stretch=2
.myImage.BackStyle=0
.DynamicFontBold = 'thisform.ShowPicture(this.'+.Name+'.myImage,zcurs.yicon)'
.Width = 20
.header1.Caption=""
.header1.Picture="vista-162.ico"
Endwith
Sele zcurs
Locate
thisform.grid1.Refresh
wait clea
for each col in thisform.grid1.columns
col.autofit
next
thisform.grid1.autofit
_screen.ellapsed=seconds()-_screen.t0
clea resources
endproc
procedure showPicture
lparameters toImage, tcImage
if inlist(lower(justext(m.tcImage)),"bmp","jpg","gif","png")
toImage.PictureVal = Nvl(filetostr(m.tcImage),'')
endi
endproc
ENDDEFINE
*
*-- EndDefine: yresults
define class ygsearch as container
width=400
height=24
backstyle=0
borderwidth=0
name="ygsearch"
Add Object text1 As TextBox With ;
FontBold = .T., ;
Height = 25, ;
Left = 16, ;
Top = 0, ;
Width = 229, ;
ForeColor = Rgb(128,0,64), ;
Name = "Text1"
Add Object yclose As Label With ;
AutoSize = .T., ;
BackStyle = 0, ;
Caption = "X", ;
autosize=.t.,;
Left = 2, ;
Top = 3, ;
ForeColor = Rgb(128,0,64), ;
mousepointer=15,;
fontsize=12,;
borderstyle=0,;
Name = "yclose"
Add Object label1 As Label With ;
AutoSize = .T., ;
BackStyle = 0, ;
Caption = "", ;
Height = 17, ;
Left = 264, ;
Top = 3, ;
Width = 2, ;
ForeColor = Rgb(255,0,0), ;
Name = "Label1"
Procedure yclose.click
thisform.yremoveSearch()
endproc
Procedure text1.LostFocus
This.parent.label1.Caption=""
Endproc
Procedure text1.InteractiveChange
sele zcurs
Local m.tot,m.n
m.n=0
m.tot=0
For Each oCol As Column In Thisform.grid1.Columns FoxObject
If Type(oCol.ControlSource)="C"
Count For Upper(Alltrim(m.this.Value)) $ Eval("UPPER(ALLTRIM("+oCol.ControlSource+"))") To m.n
m.tot=m.tot+m.n
Endi
Next
This.parent.label1.Caption=Trans(m.tot) +" occurences found "
For Each oCol As Column In Thisform.grid1.Columns FoxObject
if lower(oCol.name)=="column1"
loop
endi
If Type(oCol.ControlSource)="C"
oCol.DynamicBackColor="IIF(upper(allt(thisform.ygsearch.text1.value)) $ UPPER(ALLTRIM(" +oCol.ControlSource +")),rgb(173,255,47),RGB(255,255,255) )"
Else
oCol.DynamicBackColor=""
Endif
Next
Locate
Thisform.grid1.Refresh
Endproc
Enddefine
*-- EndDefine: ygSearch
Function ydetailOf()
Lparameters lcfilename
if pcount()<>1
return .f.
endi
Local m.x
m.x="detail of "+lcfilename+Chr(13)+Chr(13)
Dimension arrHeaders(35)
Local objShell,oBjFolder As Object
objShell = Createobject("Shell.Application")
oBjFolder = objShell.Namespace(Justpath(lcfilename))
For i = 1 To 35
arrHeaders(i) = oBjFolder.GetDetailsOf(oBjFolder.Items, i)
Next
For Each strFileName In oBjFolder.Items
If Lower(strFileName.Name)=Juststem(Allt(Lower(lcfilename)))
For i = 1 To 35
If !Empty(oBjFolder.GetDetailsOf(strFileName, i))
m.x=m.x+Trans(i)+" "+ arrHeaders(i) +" "+": " + oBjFolder.GetDetailsOf(strFileName, i)+Chr(13)
Endi
Next
Endi
Next
oBjFolder=Null
objShell=Null
messagebox(m.x,0+32+4096,"File properties")
*Return m.x
Endfunc
Note: searchMyfiles.exe can run as application directly with a configuration interface.the vfp application learn to the user how to work with command line from any application hvaving this opportunity.
download the complet project (ysearch.7z).
Important:All Codes above are tested on VFP9SP2 & windows 10 pro 64 bits version 1709(fall creator) & IE11 emulation.