Jump to content

KJohn DesktopSearch


KJohn
 Share

Recommended Posts

Source: http://koshyjohnuk.spaces.live.com/blog/cn...!1266.entry

Posted Image

Google Desktop Search takes hours to index your hard disk and then searching is not really all that great either with all sorts of irrelevant results (like showing all the contents of a folder as individual results just because the folder name matched the search query!!; Google takes great pride in the number of results returned. Hmmm.......)

Now imagine being able to index your computer in as little as 15 seconds and being able to search for files and folders in as little as 0.05 seconds. Impossible? Not with KJohn DesktopSearch! Look at the table below for a full comparison:

Feature Google DS KJohn DS

Size ~1MB ~0.3MB

Indexing time Hours Less than a minute

Search time ~0.5ms ~0.05ms

Results 10 per page All at once!

DeepScan No Yes

Performance Drop More Much lesser¹

Office 2007 Support No² Yes

Interface Generic Vista-grade

¹except when high priority indexing is requested for

²at the time of this writing

KJohn DesktopSearch supports a whopping 36 filetypes including the Office 2007 ones! A partial list: DOC,RTF,PPT,PUB, XLS, DOCX,PPTX,XLSX,PUBX, WMA,WMV,MP3,MPEG,MPG,EXE,COM,ZIP,RAR,CAB, TXT,HTML,PDF, AVI,MOV,MID,WAV, BMP,JPEG,JPG,PNG,GIF...

The entire program is contained within a self-contained executable named 'KJSearch.exe'. All you need to install or run the program is this executable. Each user on the system will need to install the software for themselves if they wish to use it. On running the executable for the first time, it automatically installs itself after asking for permission. Then indexing is run for the first time (this is likely to take much less than a minute). You can start searching your computer as soon as this is over!!!

New Features in v1.03:

1. Better documentation, including documentation relating to the Internet Explorer active content alert override.

2. Improved installer/uninstaller subroutines.

3. Online registration

4. Theme support across application (extended to About page)

5. Indexing subroutine optimisation

6. Updated results pages

Link to program: http://koshyjohnuk.googlepages.com/KJSearch.exe

Please leave comments.... Thanx!!!!

Link to comment
Share on other sites

Please leave comments.... Thanx!!!!

as this forum is called "Example Scripts", it would be nice if you could post the AU3 source. To be honest, I'm not going to run any executable someone posts in a forum. Sorry, too much risk!!

BTW: This does not mean that you tool is malicious or not good. I will just not test it without a look at the source code.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Was this made in autoit? Or did you just sign up so you could post your software?

Link to comment
Share on other sites

Was this made in autoit? Or did you just sign up so you could post your software?

Lol... amazing isn't it... It's my greatest work using AutoIt to date... I joined in June 06. Its Jan 07 now. Why would I wait so long to post this software if the primary reason I joined was to post it here?

PLUS, I've been playing with AutoIt for over 7 years now! Just coz I joined the forum only last year doesn't make me a n00b.

@/dev/null

As for the source code, i'll put up a copy of what I compiled on 18th June 2006. I'm not really inclined to share the latest version of the code. The latest version does 59 'FileInstall's and has 73 KB (1796 lines) of code. In comparison, the version I am putting up is 28 KB and contains 766 lines of code. I am unable to compile it because the files in the fileinstalls pertaining to that version have either changed location, name or both. You may not find this reassuring enough but at the moment, its the best I can do.

Looking at the code, you should be convinced of its legitimacy, considering the files created by this version will more or less be the same as the one I've compiled and put up. Feast your eyes:

PLEASE NOTE: I don't need suggestions on how to improve the code as it is really outdated anyway and I feel I've made the final version of the code in my possession just about as efficient as it can be.

; ----------------------------------------------------------------------------
;
; Author: Koshy John
; E-mail: koshyjohnuk@msn.com
; Blog  : http://spaces.msn.com/koshyjohnuk
;
; Program: FileSearch v0.76
; Purpose: To search for files on the HDD.
; Date   : 10th June 2006
;
; ----------------------------------------------------------------------------

#NoTrayIcon
#include<process.au3>;for _RunDOS
#include<file.au3>;for _FileCountLines
#include<GuiConstants.au3>;for creating the GUI

AutoItSetOption("MustDeclareVars", 0)
AutoItSetOption("RunErrorsFatal", 0)
AutoItSetOption("TrayIconDebug", 0)
AutoItSetOption("TrayIconHide", 1)
Break(0)

;=================================================
;START OF MAIN SCRIPT :: koshyjohnuk
;=================================================

;INITIALIZING PROGRAM
;====================

;setting primary variables
Global $wp=@ProgramFilesDir&"\KJohn\DSearch"
Global $title="DesktopSearch | koshyjohnuk (beta)"
Global $find,$timetaken

;checking OS version
If @OSVersion=="WIN_95" Then os()
If @OSVersion=="WIN_98" Then os()
If @OSVersion=="WIN_ME" Then os()
If @OSVersion=="WIN_NT4" Then os()
If @OSVersion=="WIN_2000" Then os()
;checking if user has admin priveleges
If IsAdmin()<>1 Then Leave()
    
;authenticating filename
If @ScriptName<>"KJSearch.exe" AND @ScriptName<>"KJSearch.au3" then Exit
;checking double run
$plist=ProcessList ("KJSearch.exe")
If $plist[0][0]>1 Then 
    WinActivate("  "&$title)
    If WinExists("  "&$title) Then Exit
    sleep(2000)
EndIf
$plist=ProcessList ("KJSearch.exe")
If $plist[0][0]>1 Then Exit
;checking location from which it is run
If @ScriptDir<>$wp Then
    If FileExists($wp&"\KJSearch.exe") Then 
        Run($wp&"\KJSearch.exe")
    Else
        DirCreate($wp)
        FileCopy(@ScriptFullPath,$wp&"\KJSearch.exe",1)
        FileDelete(@DesktopCommonDir&"\KJSearch.lnk")
        FileCreateShortcut($wp&"\KJSearch.exe",@DesktopDir&"\KJSearch.lnk","","","Search your computer quickly.",$wp&"\KJSearch.exe","",0, @SW_SHOWNORMAL)
        Run($wp&"\KJSearch.exe")
    EndIf
    Exit
EndIf

;==============================
;STARTING ACTUAL SEARCH PORTION
;==============================

;init the results page
DirRemove(@TempDir&"\kjds",1)
DirCreate(@TempDir&"\kjds")
FileInstall("top.jpg",@TempDir&"\kjds\top.jpg",1);top pic for the GUI
reindex()

;Checking Reindex schedule
If Mod(RegRead("HKCU\Software\KJohn\DSearch","ilog")+RegRead("HKCU\Software\KJohn\DSearch","iupdate"),366)<@YDAY And RegRead("HKCU\Software\KJohn\DSearch","iupdate")<>-1 Then
    FileDelete($wp&"\data\files.dat")
    FileDelete($wp&"\data\type.dat")
    FileDelete($wp&"\data\code.dat")
    FileDelete($wp&"\data\raw.dat")
    reindex()
EndIf

;USER INPUT
$find=Input()
While $find==""
    $find=Input()
WEnd

$fcom=FileOpen($wp&"\data\files.dat",0);filename
$ftype=FileOpen($wp&"\data\type.dat",0);filetype
$fcode=FileOpen($wp&"\data\code.dat",0);full file HTML code
$fimg=FileOpen($wp&"\data\imgs.dat",0);image full path

$ftot=100/(_FileCountLines($wp&"\data\files.dat")/3)
$fmod=Round(_FileCountLines($wp&"\data\files.dat")/300)
$fmodc=0

Dim $ht[7],$html[7]
;$ht[2]=0,$ht[3]=0,$ht[4]=0,$ht[5]=0,$ht[6]=0;number of files of each type found
$html[1]=FileOpen(@TempDir&"\kjds\all.htm",1)
$html[2]=FileOpen(@TempDir&"\kjds\folders.htm",1)
$html[3]=FileOpen(@TempDir&"\kjds\progs.htm",1)
$html[4]=FileOpen(@TempDir&"\kjds\docs.htm",1)
$html[5]=FileOpen(@TempDir&"\kjds\imgs.htm",1)
$html[6]=FileOpen(@TempDir&"\kjds\media.htm",1)

Global $dfiles=0;number of files found
$fj=0           ;number of files processed

;CHECKING THE CACHE
;==================
If FileExists($wp&"\cache\"&$find) Then
    Progress(-1,"Loading results from cache...","Using the cache to retrieve previous search results...")
    $timetaken=TimerInit()
    FileClose($fcom)
    FileClose($ftype)
    FileClose($fcode)
    FileClose($fimg)
    FileClose($html[1])
    FileClose($html[2])
    FileClose($html[3])
    FileClose($html[4])
    FileClose($html[5])
    FileClose($html[6])
    $cid=Run(@ComSpec &' /C copy /y "'&$wp&'\cache\'&$find&'\*.htm" "'&@TempDir&'\kjds"',"",@SW_HIDE)
    ProcessSetPriority($cid,3)
    $i=0
    While $i<100
        Progress($i)
        $i=$i+1
        If $i>101 Then ProcessWaitClose($cid)
    WEnd
    $timetaken=Round(TimerDiff($timetaken)/1000,2)
    $html[1]=FileOpen(@TempDir&"\kjds\all.htm",1)
    $html[2]=FileOpen(@TempDir&"\kjds\folders.htm",1)
    $html[3]=FileOpen(@TempDir&"\kjds\progs.htm",1)
    $html[4]=FileOpen(@TempDir&"\kjds\docs.htm",1)
    $html[5]=FileOpen(@TempDir&"\kjds\imgs.htm",1)
    $html[6]=FileOpen(@TempDir&"\kjds\media.htm",1)
    sleep(5)
    Progress(-2)
    
    Finish($html[1])
    $ie=Run(@ProgramFilesDir&'\Internet Explorer\iexplore.exe "'&@TempDir&'\kjds\all.htm"')
    Finish($html[2])
    Finish($html[3])
    Finish($html[4])
    Finish($html[5])
    Finish($html[6])
    
    ProcessWaitClose($ie)
    DirRemove(@TempDir&"\kjds",1)
    Run(@ScriptFullPath)
    Leave()
EndIf

;SCANNING THE SELECTED INDEX
;===========================
$sup=RegRead("HKCU\Software\KJohn\DSearch","sup")
If $sup="" Or $sup<10 Or $sup>2000 Then $sup=2000
Progress(-1,"Scanning index... ","Please wait while the data you requested is searched for...")
If FileExists($wp&"\crawl\"&StringLeft($find,2)&".dat")==0 Then
;if it doesn't exist in the optimised index
    $timetaken=TimerInit();TIME COUNT STARTS HERE
    While 1
        Progress(($fj*$ftot),"Scanning index... "&$dfiles&" files/folders found.")
        While $fj<$fmodc
            $fj=$fj+1
            $ft=FileReadLine($fcom)+1
            If @error=-1 Or $dfiles>=$sup Then ExitLoop 2;all files have been processed
            $f=FileReadLine($fcom)
            $fc=FileReadLine($fcom)
            If $ft=5 Then $fim=FileReadLine($fimg)
            If StringInStr($f,$find)==0 Then ContinueLoop
            FileWriteLine($html[1],$fc)
            FileWriteLine($html[$ft],$fc)
            If $ft=5 And $ht[5]<20 Then FileWriteLine($html[5],$fim)
            $ht[$ft]=$ht[$ft]+1
            $dfiles=$dfiles+1
        WEnd
        $fmodc=$fmodc+$fmod
    WEnd
    $timetaken=Round(TimerDiff($timetaken)/1000,2);END OF TIME COUNT
Else
;files possibly in the optimised index
    FileClose($fcom)
    $fcom=FileOpen($wp&"\crawl\"&StringLeft($find,2)&".dat",0);filename
    If $fcom==-1 Then Exit
    $fmod=_FileCountLines($wp&"\crawl\"&StringLeft($find,2)&".dat")/4
    $timetaken=TimerInit();TIME COUNT STARTS HERE
    While 1
        Progress(($fj*100/$fmod),"Scanning index... "&$dfiles&" files/folders found.")
        While $fj<$fmodc
            $fj=$fj+1
            $f=FileReadLine($fcom)
            If @error==-1 Or $dfiles>=$sup Then ExitLoop 2;all files have been processed
            $fc=FileReadLine($fcom)
            $ft=FileReadLine($fcom)+1
            $fim=FileReadLine($fcom)
            If StringInStr($f,$find)==0 Then ContinueLoop       
            FileWriteLine($html[1],$fc)
            FileWriteLine($html[$ft],$fc)
            If $ft=5 And $ht[5]<20 Then FileWriteLine($html[5],$fim)
            $ht[$ft]=$ht[$ft]+1
            $dfiles=$dfiles+1
        WEnd
        $fmodc=$fmodc+$fmod/100
    WEnd
    $timetaken=Round(TimerDiff($timetaken)/1000,2);END OF TIME COUNT
EndIf

;completing progress if the upper limit for results was reached
While ($fj*100/$fmod)<100
    Progress(($fj*100/$fmod),"Scanning index... "&$dfiles&" files/folders found.")
    $fj=$fj+$fmodc
WEnd

FileClose($fcom)
FileClose($ftype)
FileClose($fcode)
FileClose($fimg)
Progress(-2)

Complete($html[1],$dfiles)
Complete($html[2],$ht[2])
Complete($html[3],$ht[3])
Complete($html[4],$ht[4])
Complete($html[5],$ht[5])
Complete($html[6],$ht[6])

DirCreate($wp&"\cache\"&$find)
FileCopy(@TempDir&"\kjds\*.htm",$wp&"\cache\"&$find)

$html[1]=FileOpen(@TempDir&"\kjds\all.htm",1)
finish($html[1]);displaying results page and waiting for return | SPEED UP: even before the other files are completed
$ie=Run(@ProgramFilesDir&'\Internet Explorer\iexplore.exe "'&@TempDir&'\kjds\all.htm"')

$html[2]=FileOpen(@TempDir&"\kjds\folders.htm",1)
$html[3]=FileOpen(@TempDir&"\kjds\progs.htm",1)
$html[4]=FileOpen(@TempDir&"\kjds\docs.htm",1)
$html[5]=FileOpen(@TempDir&"\kjds\imgs.htm",1)
$html[6]=FileOpen(@TempDir&"\kjds\media.htm",1)
finish($html[2])
finish($html[3])
finish($html[4])
finish($html[5])
finish($html[6])

ProcessWaitClose($ie)
DirRemove(@TempDir&"\kjds",1)
Run(@ScriptFullPath)
Leave()
exit

;=================================================
;END OF MAIN SCRIPT :: FUNCTIONS NEXT
;=================================================

;INPUT GUI
;=========
Func Input()
    $g_input = GuiCreate("  "&$title, 390, 167,-1, -1, $WS_BORDER)
    GuiCtrlCreatePic(@TempDir&"\kjds\top.jpg", 0, 0, 390, 50)
    GuiCtrlCreateLabel("Search for :", 14, 66, 70, 20)
    GuiCtrlCreateGroup("", -19, 90, 437, 58)
    $i_search = GuiCtrlCreateInput("", 77, 63, 227, 21)
    $b_search = GuiCtrlCreateButton("Search", 313, 62, 68, 23, $BS_DEFPUSHBUTTON )
    $b_reindex = GuiCtrlCreateButton("Reindex", 23, 106, 77, 24)
    $b_optimise = GuiCtrlCreateButton("Optimise", 99, 106, 77, 24)
    $b_options = GuiCtrlCreateButton("Options", 175, 106, 77, 24)
    $b_help = GuiCtrlCreateButton(" ? ", 253, 106, 23, 24)
    $b_exit = GuiCtrlCreateButton("Exit", 294, 106, 77, 24)
    GuiSetState()
    
;***parallel processing while user inputs data
    FileInstall("Results\kjsbg.png",@TempDir&"\kjds\kjsbg.png",1)
    FileInstall("Results\logo.png",@TempDir&"\kjds\logo.png",1)
    FileInstall("Results\error.png",@TempDir&"\kjds\error.png",1)
    FileInstall("Results\bar.png",@TempDir&"\kjds\bar.png",1)
    FileInstall("Results\DEF.png",@TempDir&"\kjds\DEF.png",1)
    FileInstall("Results\DIR.png",@TempDir&"\kjds\DIR.png",1)
    FileInstall("Results\DOC.png",@TempDir&"\kjds\DOC.png",1)
    FileInstall("Results\EXE.png",@TempDir&"\kjds\EXE.png",1)
    FileInstall("Results\IMG.png",@TempDir&"\kjds\IMG.png",1)
    FileInstall("Results\PDF.png",@TempDir&"\kjds\PDF.png",1)
    FileInstall("Results\PPT.png",@TempDir&"\kjds\PPT.png",1)
    FileInstall("Results\WMP.png",@TempDir&"\kjds\WMP.png",1)
    FileInstall("Results\XLS.png",@TempDir&"\kjds\XLS.png",1)
    FileInstall("Results\ZIP.png",@TempDir&"\kjds\ZIP.png",1)
    FileInstall("Results\all.htm",@TempDir&"\kjds\all.htm",1)
    FileInstall("Results\folders.htm",@TempDir&"\kjds\folders.htm",1)
    FileInstall("Results\progs.htm",@TempDir&"\kjds\progs.htm",1)
    FileInstall("Results\docs.htm",@TempDir&"\kjds\docs.htm",1)
    FileInstall("Results\imgs.htm",@TempDir&"\kjds\imgs.htm",1)
    FileInstall("Results\media.htm",@TempDir&"\kjds\media.htm",1)
;***end of parallel processing
    
    While 1
        $msg = GuiGetMsg()
        sleep(20)
        Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $b_exit
            $i=255
            While $i>0
                WinSetTrans("  "&$title,"Search for",$i)
                If $i<50 Then 
                    $i=$i-10
                ElseIf $i<100 Then 
                    $i=$i-8
                ElseIf $i<200 Then 
                    $i=$i-6
                Else 
                    $i=$i-2
                EndIf
                sleep(10)
            WEnd
            GUIDelete()
            WinSetTrans("  "&$title,"Search for",255)
            Leave()
        Case $msg = $b_help
            MsgBox(64,$title,"KJohn DesktopSearch (beta)" & @CRLF & "Compiled on 18th June 2006" & @CRLF & @CRLF & "Created by: Koshy John" & @CRLF & "Age: 19 (u dOn't hAV 2 b olD 2 b sMarT)" & @CRLF & "E-mail: koshyjohnuk@msn.com" & @CRLF & "Blog: http://spaces.msn.com/koshyjohnuk")
        Case $msg = $b_options
            GuiSetState(@SW_HIDE,$g_input)
            option()
            GuiSetState(@SW_SHOW,$g_input)
        Case $msg = $b_optimise
            GuiSetState(@SW_HIDE,$g_input)
            optimise()
            GuiSetState(@SW_SHOW,$g_input)
        Case $msg = $b_reindex
            GuiSetState(@SW_HIDE,$g_input)
            FileDelete($wp&"\data\files.dat")
            FileDelete($wp&"\data\type.dat")
            FileDelete($wp&"\data\code.dat")
            FileDelete($wp&"\data\raw.dat")
            reindex()
            GuiSetState(@SW_SHOW,$g_input)
        Case $msg = $b_search
            $i_search = GUICtrlRead($i_search)
            If $i_search<>"" Then ExitLoop
        Case Else
        ;;;
        EndSelect
    WEnd
    GUIDelete()
    Return $i_search
EndFunc

;Options GUI
;===========
Func option()
;identifying the number of days elapsed since the last index update
    $ilog=@YDAY-RegRead("HKCU\Software\KJohn\DSearch","ilog")
    If $ilog<0 Or $ilog=@YDAY Then $ilog=0
    
    GuiCreate("  "&$title, 390, 327,-1, -1 , $WS_BORDER)
    GuiCtrlCreatePic(@TempDir&"\kjds\top.jpg", 0, 0, 390, 50)
    $Slider = GuiCtrlCreateSlider(76, 53, 251, 30)
    
    $Radio_1 = GuiCtrlCreateRadio("Every day", 20, 109, 103, 20)
    $Radio_2 = GuiCtrlCreateRadio("Once a week", 20, 130, 97, 20)
    $Radio_3 = GuiCtrlCreateRadio("Fortnightly", 20, 150, 102, 20)
    $Radio_4 = GuiCtrlCreateRadio("Monthly", 20, 170, 95, 20)
    $Radio_5 = GuiCtrlCreateRadio("Manually", 20, 190, 100, 20)
    GuiCtrlCreateLabel("Limit results to: ", 8, 59, 73, 12)
    $l_res = GuiCtrlCreateLabel("0 files", 328, 59, 130, 12)
    GuiCtrlCreateGroup("Exclude paths", 136, 90, 244, 128)
    GuiCtrlCreateGroup("Reindex", 8, 90, 121, 128)
    GuiCtrlCreateGroup("", -61, 251, 470, 69)
    GuiCtrlCreateLabel("You can exclude paths from the index to increase the speed of searches. But more the number of excluded paths, the longer it takes to index.", 143, 108, 235, 51)
    GuiCtrlCreateLabel("The file index was last updated "&$ilog&" days ago. Kindly reindex to include any files created since then.", 7, 223, 372, 30)
    $i_path = GuiCtrlCreateInput("Input path here", 143, 153, 158, 20)
    $b_browse = GuiCtrlCreateButton("Browse...", 305, 152, 70, 22)
    $b_exclude = GuiCtrlCreateButton("Exclude", 143, 184, 80, 20)
    $b_viewpaths = GuiCtrlCreateButton("View paths", 255, 184, 70, 20)
    $b_clear = GuiCtrlCreateButton("CLEAR", 325, 184, 50, 20)
    
    $b_clearcache = GuiCtrlCreateButton("Clear Cache", 210, 265, 72, 25)
    $b_done = GuiCtrlCreateButton("Done", 303, 265, 72, 25,$BS_DEFPUSHBUTTON)
    
;Setting the radio buttons in the Options GUI
    $radio_reg=RegRead("HKCU\Software\KJohn\DSearch","iupdate")
    If $radio_reg==-1 Or $radio_reg=="" Then GUICtrlSetState($Radio_5,$GUI_CHECKED)
    If $radio_reg==1 Then GUICtrlSetState($Radio_1,$GUI_CHECKED)
    If $radio_reg==7 Then GUICtrlSetState($Radio_2,$GUI_CHECKED)
    If $radio_reg==14 Then GUICtrlSetState($Radio_3,$GUI_CHECKED)
    If $radio_reg==30 Then GUICtrlSetState($Radio_4,$GUI_CHECKED)
    
;Setting the slider to the required value
    GUICtrlSetLimit($Slider,2000,10)
    $sup=RegRead("HKCU\Software\KJohn\DSearch","sup")
    If $sup="" Or $sup>2000 Or $sup<10 Then
        RegWrite("HKCU\Software\KJohn\DSearch","sup","REG_SZ",2000)
        $sup=2000
    EndIf
    GUICtrlSetData($Slider,$sup)
    GUICtrlSetData($l_res,$sup&" files")
    
    GuiSetState()
    While 1
        $msg = GuiGetMsg()
        Select
        Case $msg = $b_clearcache
            DirRemove($wp&"\Cache",1)
            GuiDelete()
            ExitLoop
        Case $msg = $GUI_EVENT_CLOSE Or $msg=$b_done
            GuiDelete()
            ExitLoop
            
    ;SLIDER UPDATE
        Case $msg = $Slider
            $sup=GuiCtrlRead($Slider)
            RegWrite("HKCU\Software\KJohn\DSearch","sup","REG_SZ",$sup)
            GUICtrlSetData($l_res,$sup&" files")
    ;END OF SLIDER UPDATE
        
    ;EXCLUDE PATHS
        Case $msg = $b_browse
            GUICtrlSetData($i_path,FileSelectFolder("Select a folder to exclude:",""))
            If GUICtrlRead($i_path)=="" Then GUICtrlSetData($i_path,"Input path here")
        Case $msg = $b_viewpaths
            If FileExists($wp&"\exclude.txt")==0 Then FileInstall("exclude.txt",$wp&"\exclude.txt")
            DirCreate(@TempDir&"\kjds")
            FileCopy($wp&"\exclude.txt",@TempDir&"\kjds\exclude.txt",1)
            Run('notepad "'&@TempDir&'\kjds\exclude.txt"')
            GUICtrlSetData($i_path,"Input path here")
        Case $msg = $b_exclude
            If FileExists($wp&"\exclude.txt")==0 Then FileInstall("exclude.txt",$wp&"\exclude.txt")
            $msg = GUICtrlRead($i_path)
            If FileExists($msg) Then
                $flag = 0
                $f_exc = FileOpen($wp&"\exclude.txt",0)
                While 1
                    $p_dir = FileReadLine($f_exc)
                    If @error = -1 Then ExitLoop
                    If StringInStr($msg,$p_dir) Then $flag = 1
                WEnd
                FileClose($f_exc)
                If $flag = 0 Then 
                    FileWriteLine($wp&"\exclude.txt",$msg)
                    GUICtrlSetData($i_path,"Excluded: "&$msg)
                    sleep(800)
                    GUICtrlSetData($i_path,"Input path here")
                Else
                    GUICtrlSetData($i_path,"Error: Already excluded")
                EndIf
            Else
                GUICtrlSetData($i_path,"Input path here")
            EndIf
        Case $msg = $b_clear
            FileDelete($wp&"\exclude.txt")
            FileInstall("exclude.txt",$wp&"\exclude.txt")
            GUICtrlSetData($i_path,"All path exclusions cleared!")
            sleep(1000)
            GUICtrlSetData($i_path,"Input path here")
    ;END OF EXCLUDE PATHS
        
    ;INDEX UPDATE FREQUENCY
        Case $msg >= $Radio_1 And $msg <=$Radio_5
            $radioval = $msg - $Radio_1
            Select
            Case $radioval=0
                RegWrite("HKCU\Software\KJohn\DSearch","iupdate","REG_SZ",1)
            Case $radioval=1
                RegWrite("HKCU\Software\KJohn\DSearch","iupdate","REG_SZ",7)
            Case $radioval=2
                RegWrite("HKCU\Software\KJohn\DSearch","iupdate","REG_SZ",14)
            Case $radioval=3
                RegWrite("HKCU\Software\KJohn\DSearch","iupdate","REG_SZ",30)
            Case $radioval=4
                RegWrite("HKCU\Software\KJohn\DSearch","iupdate","REG_SZ",-1)
            EndSelect
    ;END OF INDEX UPDATE FREQUENCY
            
        Case Else
        ;;;
        EndSelect
    WEnd
    GUIDelete()
EndFunc

;GUI Progress Area
;=================
Func Progress($do,$subtext="",$doing="")
    If $do=-1 Then
        GuiCreate("  "&$title, 390, 167,-1, -1 , $WS_BORDER)
        GuiCtrlCreatePic(@TempDir&"\kjds\top.jpg", 0, 0, 390, 50)
        Global $l_stat = GuiCtrlCreateLabel($doing, 10, 57, 350, 13)
        Global $p_status = GuiCtrlCreateProgress(10, 81, 367, 18)
        Global $l_subtext = GuiCtrlCreateLabel($subtext, 10, 110, 350, 13)
        GuiSetState()
    ElseIf $do=-2 Then
        GUIDelete()
    Else
        If $doing<>"" Then GUICtrlSetData($l_stat,$doing)
        If $subtext<>"" Then GUICtrlSetData($l_subtext,$subtext)
        GUICtrlSetData($p_status,$do)
    EndIf
EndFunc

;GUI Scanning Drives
;===================
Func guidscan($do,$subtext="",$doing="")
    If $do=-1 Then
        FileInstall("scan.bin",@TempDir&"\kjds\scan.bin",1)
        GuiCreate("  "&$title, 390, 167,-1, -1, $WS_BORDER)
        GUISetBkColor(0xFFFFFF)
        GuiCtrlCreatePic(@TempDir&"\kjds\top.jpg", 0, 0, 390, 50)
        Global $l_stat = GuiCtrlCreateLabel("Scanning drive C:... Please wait.", 115, 74, 350, 13);doing
        GUICtrlCreateAvi(@TempDir&"\kjds\scan.bin",-1,20,64,-1,-1,$ACS_AUTOPLAY)
        Global $l_subtext = GuiCtrlCreateLabel($subtext, 115, 91, 351, 20);subtext
        GuiSetState()
    ElseIf $do=-2 Then
        FileDelete(@TempDir&"\kjds\scan.bin")
        GUIDelete()
    Else
        If $doing<>"" Then GUICtrlSetData($l_stat,$doing)
        If $subtext<>"" Then GUICtrlSetData($l_subtext,$subtext)
    EndIf
EndFunc

;COMPLETING SEARCH RESULTS PAGE(S)
;================================
Func complete($page,$no)
    FileWriteLine($page,"</table>")
;checking if no files/folders found
    If $no==0 Then FileWriteLine($page,"<p></p><center><img src=error.png><font face=Tahoma size=4 color=gray> No folders or files of this type were found! </font><p><font face=Tahoma size=2 color=lightgray>Try some other file type(s) or search term(s). </font></p></center>")
;completing the results page code
    FileWriteLine($page,"<p></p><p></p><div style='mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .75pt;padding:0in 0in 1.0pt 0in'></div><p></p><p></p>")
    FileWriteLine($page,"<table border=0 cellspacing=0 cellpadding=0><tr><td><font size=2><b>You searched for '"&$find&"' on "&@ComputerName&".</b></font></td></tr>")
    FileWriteLine($page,"<tr><td><font size=2><b>Files/Folders Found: "&$dfiles&"</b> ("&$no&" of selected type)</font></td></tr> <tr><td><font size=2><b>Total files/folders on System: "&_FileCountLines($wp&"\data\raw.dat")&"</b></font></td></tr>")
    FileClose($page)
EndFunc

Func finish($page)
    FileWriteLine($page,"<tr><td><font size=2><b>Time taken: "&$timetaken&" seconds.</b></font></td></tr></table><p></p>")

    FileWriteLine($page,"<p><font size=2><b>© Koshy John "&@YEAR&". All rights reserved.</b></font></p><p></p>")
    FileWriteLine($page,"</body></html>")
    FileClose($page)
EndFunc

;INDEXING FUNCTION
;=================
Func reindex()
    Global $drives=DriveGetDrive("FIXED"),$drindex
    DirCreate($wp&"\data")
    If FileExists($wp&"\data\raw.dat") Then Return
;starting the scan operation when the index files are not found
    $i=1
    guidscan(-1)
    While $i<=$drives[0]
        If DriveStatus($drives[$i]&"\")=="READY" Then
            $drindex=Run(@ComSpec &" /C dir /s /b "&$drives[$i]&'\*.* >"'&$wp&'\data\scan'&$i&'.dat"',"",@SW_HIDE)
            sleep(50)
            guidscan(1,"Files found on drive '"&StringUpper($drives[$i])&"' : "&_FileCountLines($wp&'\data\scan'&$i&'.dat'),"Scanning "&StringUpper($drives[$i])&"... Please wait.")
            While(ProcessExists($drindex))
                sleep(30)
                guidscan(1,"Files found on drive '"&StringUpper($drives[$i])&"' : "&_FileCountLines($wp&'\data\scan'&$i&'.dat'))
            WEnd
            sleep(500)
        EndIf
        $i=$i+1
    WEnd
    RunWait(@ComSpec &' /C copy /y /a "'&$wp&'\data\scan*.dat" "'&$wp&'\data\raw.dat"',"",@SW_HIDE)
    RunWait(@ComSpec &' /C del /f /q "'&$wp&'\data\scan*.dat"',"",@SW_HIDE)
    guidscan(-2)
    
;CONCISE INDEX
;=============
;loading path exclusions
    $pn=0
    If FileExists($wp&"\exclude.txt") Then
        $pn=_FileCountLines($wp&"\exclude.txt")
        If $pn>20 Then $pn=20
        Dim $pathex[$pn+1]
        $pi=1
        While $pi<=$pn
            $pathex[$pi]=FileReadLine($wp&"\exclude.txt",$pi)
            $pi=$pi+1
        WEnd
    EndIf
;completed loading path extensions
    
    Progress(-1,"Estimated Time Remaining : Unknown","Please wait while the index is compiled...")
    $raw=FileOpen($wp&"\data\raw.dat",0)
    $fcom=FileOpen($wp&"\data\files.dat",2);filename
    $fimg=FileOpen($wp&"\data\imgs.dat",2);image full path code
    
    $ftot=_FileCountLines($wp&"\data\raw.dat")
    $avoid="*";speed up technique
    
    $rts=TimerInit();reindex time start
    For $fj=1 To $ftot Step 1
        $f=FileReadLine($raw)
        If @error=-1 Then ExitLoop
        If Mod($fj,50)==1 Then 
            $rtl=Round(($ftot-$fj)*TimerDiff($rts)/(1000*$fj))
            Progress($fj*100/$ftot,$f,"Compiling index... Estimated time remaining: "&$rtl&" seconds.")
        EndIf
            
    ;path check
        If StringInStr($f,$avoid)<>0 Then ContinueLoop
        If StringInStr($f,":\Program Files\")<>0 Or StringInStr($f,@ProgramFilesDir)<>0 And StringLower(StringRight($f,4))<>".exe" Then ContinueLoop
        If StringInStr($f,":\Windows")<>0 Or StringInStr($f,@WindowsDir)<>0 Or StringInStr($f,":\Recycler")<>0 Or StringInStr($f,"\Local Settings\")<>0 Or StringInStr($f,"\Cookies\")<>0 Or StringInStr($f,"\Clipart")<>0 Or StringInStr($f,"\Files\PFiles")<>0 Then 
            $avoid=$f
            ContinueLoop
        EndIf
            
    ;checking user defined paths
        For $pi=1 To $pn Step 1
            If StringInStr($f,$pathex[$pi])<>0 Then 
                $avoid=$pathex[$pi]
                ContinueLoop 2
            EndIf
        Next
        
    ;file type
        $fatt0=FileGetAttrib($f)
        $ext=StringLower(StringRight($f,4))
        If StringInStr($fatt0,"H") Or StringInStr($fatt0,"S") Then
            $avoid=$f
            ContinueLoop
        ElseIf StringInStr($fatt0,"D") Then 
            $ext="DIR"
            FileWriteLine($fcom,"1")
        ElseIf $ext==".bmp" Or $ext==".png" Or $ext==".gif" Or $ext==".jpg" Or $ext=".jpeg" Then
            $ext="IMG"
            FileWriteLine($fcom,"4")
            FileWriteLine($fimg,'<tr><td></td><td><img src="'&$f&'" width=120></td></tr>')
        ElseIf $ext==".wav" Or $ext==".avi" Or $ext==".mov" Or $ext==".wma" Or $ext==".wmv" Or $ext==".mid"  Or StringInStr($ext,".mp") Then
            $ext="WMP"
            FileWriteLine($fcom,"5")
        ElseIf $ext==".exe" Or $ext==".com" Then
            $ext="EXE"
            FileWriteLine($fcom,"2")
        ElseIf $ext==".doc" Or $ext==".rtf" Then
            $ext="DOC"
            FileWriteLine($fcom,"3")
        ElseIf $ext==".zip" Or $ext==".cab" Or $ext==".rar" Then
            $ext="ZIP"
            FileWriteLine($fcom,"1")
        ElseIf $ext==".txt" Or $ext=="html" Or $ext==".htm" Then
            $ext="DEF"
            FileWriteLine($fcom,"3")
        ElseIf $ext==".pdf" Then
            $ext="PDF"
            FileWriteLine($fcom,"3")
        ElseIf $ext==".ppt" Then
            $ext="PPT"
            FileWriteLine($fcom,"3")
        ElseIf $ext==".xls" Then
            $ext="XLS"
            FileWriteLine($fcom,"3")
        Else
            $avoid=$ext
            ContinueLoop
        EndIf
    
    ;file name
        $fsplit=StringSplit($f,"\")
        $fname=$fsplit[$fsplit[0]]
        $fnamel=StringLen($fname)
        FileWriteLine($fcom,$fname)
    
    ;file path
        $fpath1=StringTrimRight($f,$fnamel)
    
    ;file size
        $fsize=FileGetSize($f)
        If $fsize<=0 Then $fsize=DirGetSize($f);size of folder
        $fsize=Round($fsize/1048576,2)
        If $fsize==0 Then $fsize="< 0.01"
    
    ;last modified
        $fgtime=FileGetTime($f)
        If @error<>1 Then 
            $ftime=$fgtime[0]&"-"&$fgtime[1]&"-"&$fgtime[2]&", "&$fgtime[3]&":"&$fgtime[4]
        Else 
            $ftime="Unknown"
        EndIf
    
    ;file HTML code
        If $fnamel>35 Then $fname=StringLeft($fname,35)&"..."
        FileWriteLine($fcom,'<tr><td><img src='&$ext&'.png></td><td><a href="'&$f&'"><font size=2>'&$fname&"</font></a></td><td><font size=2>"&$fsize&"MB</font></td><td><font size=2>"&$ftime&'</font></td><td><a href="'&$fpath1&'"><font size=2>'&$fpath1&"</font></a></td></tr>")
    Next
    
    Progress(-2)
    FileClose($fcom)
    FileClose($raw)
    FileClose($fimg)
    
    RegWrite("HKCU\Software\KJohn\DSearch","ilog","REG_SZ",@YDAY)
    
    DirRemove($wp&"\crawl",1)
    DirCreate($wp&"\crawl")
    DirRemove($wp&"\cache",1)
    DirCreate($wp&"\cache")
EndFunc

;CREATING THE HYPERSEARCH INDEX
;==============================
Func optimise()
    Progress(-1,"Starting optimisation...","Please wait while an optimised index is compiled...")
    DirRemove($wp&"\crawl",1)
    DirCreate($wp&"\crawl")
    
    $fcom=FileOpen($wp&"\data\files.dat",0);filename
    $fimg=FileOpen($wp&"\data\imgs.dat",0);imagecode
    $ftot=_FileCountLines($wp&"\data\files.dat")/3
    $rts=TimerInit()
    For $fj=1 To $ftot Step 1
        $ft=FileReadLine($fcom)
        If @error=-1 Then ExitLoop
        $f=FileReadLine($fcom)
        $fc=FileReadLine($fcom)
        If $ft=4 Then 
            $img=FileReadLine($fimg)
        Else
            $img=" "
        EndIf
        If Mod($fj,30)==1 Then 
            $rtd=Round($fj*1000/TimerDiff($rts))
            Progress($fj*100/$ftot,"Processing: "&$rtd&" files/sec. Remaining: "&Round(($ftot-$fj)/$rtd)&" secs.")
        EndIf
        
    ;file name
        $fsplit=StringSplit($f," _.,-()")
        For $i=1 To $fsplit[0] Step 1
            If StringIsAlNum($fsplit[$i]) And StringLen($fsplit[$i])>=2 Then
                $cfile=FileOpen($wp&"\crawl\"&StringLeft($fsplit[$i],2)&".dat",1)
                FileWriteLine($cfile,$f)
                FileWriteLine($cfile,$fc)
                FileWriteLine($cfile,$ft)
                FileWriteLine($cfile,$img)
                FileClose($cfile)
            EndIf
        Next
    Next
    sleep(1000)
    Progress(-2)
    FileClose($fcom)
    FileClose($fimg)
EndFunc

;USER INTERRUPT
;==============
Func Leave()
;closing all indexing processes
    DirRemove(@TempDir&"\kjds",1)
    Exit
EndFunc

;CHECKING OS VERSION
;===================
Func os()
    MsgBox ( 48, $title, "Your Windows version is "& @OSVersion &".", 15)
    exit
endfunc
Link to comment
Share on other sites

I managed to find a copy of the executable I compiled on 20th June 2006. If you are curious, you can run it; but please note the following:

- Set your system date to somewhere close to the 20th June 2006 period before you run it.

- Make sure Program files\KJohn\DSearch doesn't exist

- Run the executable

- It is much slower than the latest version but its faster than the faster ever script put up on this forum.

- Indexing is slower (takes up to 4 times as long as the latest; OLD ALGORITHM)

- Searching, however, will take less than a second.

- This version will only run on an administrative account (you can see why in the above source code). The newer version can run on any type of account.

Comments are most welcome! I've spent long months working on this!!!

Link to comment
Share on other sites

Just for the curious: Here's a primitive version of my program that encouraged me to go on. Its so primitive that it can co-exist with the other version I've put up. I don't think this one needs to run from an administrative account. It has to be started each time, it won't return to the search interface after the results of a previous search are displayed.

It can be run from anywhere. There is no installer/uninstaller.

Manually delete the index: C:\Documents and Settings\<USERNAME>\Local Settings\Application Data\KJS

Link to comment
Share on other sites

Correct me if I'm wrong, but this does not index file content does it?

nope it doesn't... how can u expect that much in 30 seconds? i just don't have the expertise to scan the contents of documents, ppts, etc... if anyone has any idea, cud u give me a pointer?

Link to comment
Share on other sites

So why brag about it being better and faster than Google Desktop? It's not comparable at all! Not even by fare.

Link to comment
Share on other sites

So why brag about it being better and faster than Google Desktop? It's not comparable at all! Not even by fare.

wht u r saying is true from a point of view... but i beg to differ... My program does what it was made to do and does it well... for people who are not interested in searching within files, Google Desktop is just a hog which comes with a lot of added crap that very few people WANT.... for such people, (i know many; myself included) my program is a dream come true... do u agree with that? setting aside the feature of searching within files...

and i don't think u can find a faster program than mine on this forum or elsewhere that does what i hav said it would... can u?

i'm open to discussion...

Link to comment
Share on other sites

and i don't think u can find a faster program than mine on this forum or elsewhere that does what i hav said it would... can u?

i'm open to discussion...

many out there.... Just one example: http://www.harddisksearch.com/. Can also search content of files.

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

wht u r saying is true from a point of view... but i beg to differ... My program does what it was made to do and does it well... for people who are not interested in searching within files, Google Desktop is just a hog which comes with a lot of added crap that very few people WANT.... for such people, (i know many; myself included) my program is a dream come true... do u agree with that? setting aside the feature of searching within files...

All I'm saying is that you compare oranges with bananas. They are both fruits and taste good. But that is where the comparison stops. So bragging about how much better your banana is compared to the oranges in the shop does not make any sense.

and i don't think u can find a faster program than mine on this forum or elsewhere that does what i hav said it would... can u?

i'm open to discussion...

There is nothing novel in the way you do you search. There are several samples doing exactly the same. I have used the same technique for years. Create a db file with dir and use grep to find files with a name matching what I'm searching for. Does the same thing as your script without all the fancy stuff. And yes my way of doing it is probably faster as I don't have the overhead of the AutoIt script engine and GUI stuff.

With all that said. As long as your happy with your script and it works for you. Thats good.

And you have proven that you manage several programing techniques. So that is good.

Happy Scripting..:whistle:

Link to comment
Share on other sites

So basically...

dir /s/b > files.dat (updated via Scheduled Task)

findstr /i "search_string" files.dat

but with a fancy GUI? Or did I miss something?

-John

Results should be similar... the algorithm used is completely different though...

I do a lot of processing after the 'files.dat' creation stage (as per your code)... one time (pre)processing that'll speed up searches... And I use AutoIt to do the 'findstr' sections..

You implementation will be faster per se but i don't think you can build a GUI out of it easily without sacrificing performance during generation of results... think about it...

And the cmd prmpt interface is not really the best when a search returns a lot of files... my opinion; everyone's entitled to theirs...

Link to comment
Share on other sites

IMPORTANT

And yes findstr will not be successful in an example as follows:

The file you are looking for is "Google - The best search engine.txt"

In your implementation, searching for "Google txt" will not return that file

but my implementation will give the desired results...

am i right (with regards to your implementation; i know mine will work)?

Or "best engine" or "Google search" or... so on...

Get it?

Link to comment
Share on other sites

And how about finding files starting with test having google in them and ending with txt or dat ?

find is not grep. The nice thing with grep is called regexp..:whistle:. And, as long as you only search for a filename you will probably find your desired result at a glance or with a refined search in the command window. The problem is that you can't find files containing StringRegExp, and that Google Desktop will do.

Obviously you can search for a know file (or type) and use the file name to do a content search.

Now, if you want to make a tool similar to Google Desktop you could index the content of all the files with a btree UDF. I have seen udf's it in the forum so it can be done with AutoIt. You also have SQLite and ADO options. But the easies way is to use something like swish++. And, yes, swish++ can be used from cmd prompt to..:)

Link to comment
Share on other sites

And how about finding files starting with test having google in them and ending with txt or dat ?

find is not grep. The nice thing with grep is called regexp..:whistle:. And, as long as you only search for a filename you will probably find your desired result at a glance or with a refined search in the command window. The problem is that you can't find files containing StringRegExp, and that Google Desktop will do.

Obviously you can search for a know file (or type) and use the file name to do a content search.

Now, if you want to make a tool similar to Google Desktop you could index the content of all the files with a btree UDF. I have seen udf's it in the forum so it can be done with AutoIt. You also have SQLite and ADO options. But the easies way is to use something like swish++. And, yes, swish++ can be used from cmd prompt to..:)

I didn't understand half of what you said in the second paragraph...

But about the example you mentioned... Google Desktop does not support an OR query... Only logical AND... (upto version 4 anyway; i won't install 5... i just hate having all those processes running in the background forever..)

anyway, you can't check for txt or dat in a single query in google desktop... OR is supported only in web search queries...

i haven't started playing with regular expressions enough to be able to incorporate it into my program at the moment...

As for searching within files, i've progressed this far in feasibilty:

- searching within txt and html and all similar ASCII files...

- searching within metadata of files...

- searching within PDFs

I still haven't figured out how to convert:

- DOC, XLS, PPT into txt to index

- DOCX, XLSX,PPTX into txt (all these are just compressed files that can be unzipped)

Uten, since you've taken interest in this so far, wht other files would you be interested in searching WITHIN?

I have a feeling I'll still be able to beat Google Desktop even if I incorporate the above functionality... but it all depends on how fast the conversion to txt process will take per file... so no claims at this point...

Just out of curiosity, how does google manage to take queries off a HTML file running in Internet Explorer? It loopsback to 127.0.0.1 and makes your computer a server serving itself???

Link to comment
Share on other sites

I have a feeling I'll still be able to beat Google Desktop even if I incorporate the above functionality... but it all depends on how fast the conversion to txt process will take per file... so no claims at this point...

you should really stay realistic!

Searching is the main business of google and they do it pretty good. I doubt, you will ever be faster than Google Desktop with an application written in AutoIT and with less then 10 years of development in the search algorithms, database design, etc.

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

you should really stay realistic!

Searching is the main business of google and they do it pretty good. I doubt, you will ever be faster than Google Desktop with an application written in AutoIT and with less then 10 years of development in the search algorithms, database design, etc.

Google has additional functionality that I won't be incorporating... like a timeline for files.. and other such stuff... my only priority would be to include searching within files and their metadata... I like staying to the point and cutting the crap... There are many features in Google desktop that "normal" people don't use... these features come with a huge overhead...

I've analysed search algorithms for over 2 years now but it was only AutoIt that gave me a platform to implement it by myself without working with a larger team as AutoIt cuts out things I really don't have to look at if I was using the regular Windows APIs...

I've used Google Desktop... Plz note that I love Google and all that... but they program just returns too many irrelevant results... its just like their web search... they place priority on quantity of results rather than quality... I really feel so... becoz its really difficult to find stuff without tweaking your search term multiple times and many times even that is not enough...

I want to better that... for myself because I am tired of the crap it serves... if others like it too, well and good...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...