Sign in to follow this  
Followers 0
ashley

SimpleSearch V.1.4 'Build 2' *updated 1st sept 07*

32 posts in this topic

#1 ·  Posted (edited)

Ok i have made a program like 'neosearch' but i have called it 'SimpleSearch'

Known bugs:

1)Only search for .* files

TODO list:

1) make it show just the filename(not the whole path)

2) make it search for anything that is typed (e.g. ashley not just .files)

3) get runfiles/dubble-click opening work

4) add search using index

Latest update features:

1) Indexing

2) Installer

Downloads:

1) SimpleSearch.exe

2) SimpleSearch Script

If you find any bugs in the installer or the program please let me know so that i can fix them.

Edited by ashley

Share this post


Link to post
Share on other sites

I think your timer might not work becasue you are declaring variable in a function rather thatn globally. To make only the file name appear couldnt you use Stringinstrg to a back slash and then cut off the rest?

Share this post


Link to post
Share on other sites

That file search looks familiar... is that the one Randal did?


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

Share this post


Link to post
Share on other sites

Try working with this code (its one of the oldest versions of KJohn DesktopSearch; KJDS preceeded neoSearch):

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

#NoTrayIcon
#include<process.au3> ;for _RunDOS
#include<file.au3> ;for _FileCountLines

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

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

;INITIALIZING PROGRAM
;====================
HotKeySet("{ESC}", "Leave")

;checking windows partition
Global $wp=@ProgramFilesDir&"\KJohn\DSearch"
Global $title="DesktopSearch | koshyjohnuk"

;SCANNING DRIVES IN THE BACKGROUND
;---------------------------------

;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()

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

;init the results page
DirRemove(@TempDir&"\kjds",1)
DirCreate(@TempDir&"\kjds")
FileInstall("Results\kjds.htm",@TempDir&"\kjds\all.htm",1)
FileInstall("Results\kjsbg.png",@TempDir&"\kjds\kjsbg.png",1)
FileInstall("Results\logo.png",@TempDir&"\kjds\logo.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)

$html=FileOpen(@TempDir&"\kjds.htm",1)

;USER INPUT
$find=InputBox($title,"Enter a part of the name of the file/folder you want to find:"&@LF&"(Tip: Input '?' for help with advanced features)",""," M",320,140)
If $find=="/reindex" Then reindex()
If $find=="" Then Exit
If $find=="?" Then $find=InputBox($title,"Enter a part of the name of the file/folder you want to find:"&@LF&@LF&"Syntax: string [/d:driveletter] [/deep] [/s:min,max] [/a:RASHNDOCT] [/ex-str1-str2...] [/reindex]",""," M",320,170)
If $find=="" Then Exit

$timetaken=TimerInit() ;TIME COUNT STARTS HERE

;SCANNING THE SELECTED INDEX
;===========================
$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

ProgressOn($title,"","Scanning index... 0 files/folders found.")
$ftot=100/_FileCountLines($wp&"\data\files.dat")
$fmod=5*Round(_FileCountLines($wp&"\data\files.dat")/100)
$fmodc=0
$html=FileOpen(@TempDir&"\kjds\all.htm",1)

Global $dfiles=0 ;number of files found
$dfilesold=0     ;number of files found in the previous iteration
$fj=0            ;number of files processed
While 1
    ProgressSet(($fj*$ftot),"Scanning index... "&$dfiles&" files/folders found.")
    While $fj<$fmodc
        $fj=$fj+1
        $f=FileReadLine($fcom)
        If @error=-1 Then ExitLoop 2 ;all files have been processed
        $fc=FileReadLine($fcode)
        $ft=FileReadLine($ftype)
        If StringInStr($f,$find)==0 Then ContinueLoop
        FileWriteLine($html,$fc)
        $dfiles=$dfiles+1
    WEnd
    $fmodc=$fmodc+$fmod
WEnd
FileClose($fcom)
FileClose($ftype)
FileClose($fcode)
ProgressOff()

$timetaken=Round(TimerDiff($timetaken)/1000,2) ;END OF TIME COUNT

;completing the results page code
FileWriteLine($html,"</table>")
FileWriteLine($html,"<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($html,"<table border=0 cellspacing=0 cellpadding=0><tr><td><font size=2><b>You searched for '"&$find&"' on "&@ComputerName&".</b></font></td></tr>")
FileWriteLine($html,"<tr><td><font size=2><b>Files/Folders Found: "&$dfiles&"</b></font></td></tr> <tr><td><font size=2><b>Total files/folders on System: "&_FileCountLines(@UserProfileDir&"\Local Settings\Application Data\KJS\kjsall.dat")&"</b></font></td></tr> <tr><td><font size=2><b>Total time taken: "&$timetaken&" seconds.</b></font></td></tr></table><p></p>")

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

;displaying results page and waiting for return
ProcessWaitClose(Run(@ProgramFilesDir&'\Internet Explorer\iexplore.exe "'&@TempDir&'\kjds\all.htm"'))

Leave()
exit

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

;INDEXING FUNCTION
;=================
Func reindex()
    Global $drives=DriveGetDrive("FIXED"),$drindex
    If FileExists($wp&"\data\raw.dat")==0 Then
        ;starting the scan operation when the index files are not found
        $i=1
        While $i<=$drives[0]
            If DriveStatus($drives[$i]&"\")=="READY" Then
                $drindex=Run(@ComSpec &" /C dir /s /a:-H-S /b "&$drives[$i]&'\*.* >"'&$wp&'\data\scan'&$i&'.dat"',"",@SW_HIDE)
                sleep(200)
                While(ProcessExists($drindex))
                    sleep(30)
                    $fcltxt="Scanning "&StringUpper($drives[$i])&"... "&_FileCountLines($wp&'\data\scan'&$i&'.dat')&" files found."
                    SplashTextOn($title,$fcltxt,300,18,-1,-1,17,10)
                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)
        SplashOff()
    EndIf

    ;CONCISE INDEX
    ProgressOn($title,"Compiling index...","",-1,-1,16)
    $raw=FileOpen($wp&"\data\raw.dat",0)
    $fcom=FileOpen($wp&"\data\files.dat",2) ;filename
    $ftype=FileOpen($wp&"\data\type.dat",2) ;filetype
    $fcode=FileOpen($wp&"\data\code.dat",2) ;full file HTML code
    $ftot=_FileCountLines($wp&"\data\raw.dat")
    For $fj=1 To $ftot Step 1
        $f=FileReadLine($raw)
        If @error=-1 Then ExitLoop
        If Mod($fj,30)==0 Then ProgressSet($fj*100/$ftot,$f)
            
        ;path check
        If StringInStr($f,":\Windows\")<>0 Or StringInStr($f,@WindowsDir)<>0 Then ContinueLoop
        If StringInStr($f,":\Program Files\")<>0 Or StringInStr($f,@ProgramFilesDir)<>0 Then
            $fatt0=FileGetAttrib($f)
            $ext=StringRight($f,4)
            $ext=StringLower($ext)
            If $ext<>".exe" And $ext<>".pdf" And $ext<>".chm" And $ext<>".txt" And StringInStr($fatt0,"D") Then ContinueLoop
        EndIf
        If StringInStr($f,"\Local Settings\")<>0 Or StringInStr($f,"\Application Data\")<>0 Then ContinueLoop
        If StringInStr($f,":\Recycler\")<>0 Or StringInStr($f,"\Application Data\")<>0 Then ContinueLoop
        If StringInStr($f,"\$Ntu")<>0 Then ContinueLoop
    
        ;file type
        $fatt0=FileGetAttrib($f)
        $ext=StringRight($f,4)
        $ext=StringLower($ext)
        If StringInStr($fatt0,"D") Then 
            $ext="DIR"
        ElseIf $ext==".bmp" Or StringInStr($ext,".jp") Or $ext=="jpeg" Or $ext==".png" Or $ext==".gif" Then
            $ext="IMG"
        ElseIf $ext==".wav" Or $ext==".avi" Or $ext==".mov" Or $ext=="mpeg" Or StringInStr($ext,".mp") Or StringInStr($ext,".wm") Then
            $ext="WMP"
        ElseIf $ext==".exe" Or $ext==".com" Then
            $ext="EXE"
        ElseIf $ext==".doc" Or $ext==".rtf" Then
            $ext="DOC"
        ElseIf $ext==".zip" Or $ext==".cab" Or $ext==".rar" Then
            $ext="ZIP"
        ElseIf $ext==".txt" Or $ext=="html" Or $ext==".htm" Then
            $ext="DEF"
        ElseIf $ext==".pdf" Then
            $ext="PDF"
        ElseIf $ext==".ppt" Then
            $ext="PPT"
        ElseIf $ext==".xls" Then
            $ext="XLS"
        Else
            ContinueLoop
        EndIf
        FileWriteLine($ftype,$ext)
    
        ;file name
        $fsplit=StringSplit($f,"\")
        $fname=$fsplit[$fsplit[0]]
        FileWriteLine($fcom,$fname)
    
        ;file path
        $fpath1=$fsplit[1]
        $i=2
        While $i<$fsplit[0]
            $fpath1=$fpath1&"\"&$fsplit[$i]
            $i=$i+1
        WEnd
    
        ;file size
        $fsize=FileGetSize($f)
        If $fsize<=0 Then $fsize=DirGetSize($f) ;size of folder
        $fsize=Round($fsize/1048576,2)
    
        ;last modified
        $fgtime=FileGetTime($f)
        $ftime=$fgtime[0]&"-"&$fgtime[1]&"-"&$fgtime[2]&", "&$fgtime[3]&":"&$fgtime[4]
    
        ;file HTML code
        If StringLen($fname)>35 Then $fname=StringLeft($fname,35)&"..."
        FileWriteLine($fcode,'<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

    FileClose($fcode)
    FileClose($fcom)
    FileClose($ftype)
    FileClose($raw)
EndFunc

;USER INTERRUPT
;==============
Func Leave()
    ;closing all indexing processe
    
    _RunDOS("del /f /q "&$wp&"\index*.dat")
    FileDelete($wp &"\ntfs.dat")
    FileDelete($wp &"\kjsall.dat")
    FileDelete(@TempDir&"\kjs*.png")
    FileDelete(@TempDir&"\kjds.htm")
    exit
endfunc

;CHECKING OS VERSION
;===================
Func os()
    MsgBox ( 48, $title, "Your Windows version is "& @OSVersion &".", 15)
    exit
endfunc

;SMOOTHENING PROGRESS BAR
;========================
Func count($ca,$cb,$cs)
$ci=$ca
Do
   If $cs<>"" Then 
       ProgressSet ($ci,$ci&" % | " & $cs)
   Else 
       ProgressSet($ci)
   EndIf
   $ci=$ci+1
Until $ci>=$cb
endfunc

It should serve as a good starting point for people intending to make a desktop search engine in AutoIt. But I really suggest you don't look at my code, since it might prevent you from finding a better method than mine.... Use it only if you have no idea how to go about making one...

Share this post


Link to post
Share on other sites

That file search looks familiar... is that the one Randal did?

im not sure...

Sombody gave it to me...

@sccrstvn93

Thanks ill try that...

@Koshy John

I know i have been... but its just as good with out indexing... (ATM, i will get round to making a indexing func)

Share this post


Link to post
Share on other sites

im not sure...

Sombody gave it to me...

@sccrstvn93

Thanks ill try that...

@Koshy John

I know i have been... but its just as good with out indexing... (ATM, i will get round to making a indexing func)

Its fast (without indexing) because the file system table is cached into RAM the first time the program is run... The increase in speed will remain only as long as some other programs don't request additional RAM (causing the cache to be discarded)... The cache is usually also overwritten after a period of time to enhance the performance of other systems by caching data for them into RAM...

To measure the actual performance:

1. Restart your computer (this is a sure fire way to clear the cache).

2. Run your program for a single query (recursively). The speed of this is the actual speed of your program.

The increase in speed you experience will not be consistent on different configurations of systems because of the cache factor.

To really understand what I'm talking about, go to the root folder of the drive containing Windows using Command prompt:

1. Run 'dir /s /a' once. Note the time taken and the level of HDD activity.

2. Run the command again as soon as it completes. Note the time taken and the level of HDD activity.

In the second case, HDD activity will be negligible most of the time and the speed at which the results are rendered is only restricted by the speed of your CPU.

Share this post


Link to post
Share on other sites

Its fast (without indexing) because the file system table is cached into RAM the first time the program is run... The increase in speed will remain only as long as some other programs don't request additional RAM (causing the cache to be discarded)... The cache is usually also overwritten after a period of time to enhance the performance of other systems by caching data for them into RAM...

To measure the actual performance:

1. Restart your computer (this is a sure fire way to clear the cache).

2. Run your program for a single query (recursively). The speed of this is the actual speed of your program.

The increase in speed you experience will not be consistent on different configurations of systems because of the cache factor.

To really understand what I'm talking about, go to the root folder of the drive containing Windows using Command prompt:

1. Run 'dir /s /a' once. Note the time taken and the level of HDD activity.

2. Run the command again as soon as it completes. Note the time taken and the level of HDD activity.

In the second case, HDD activity will be negligible most of the time and the speed at which the results are rendered is only restricted by the speed of your CPU.

ok

i have made an update...

Check first post...

Share this post


Link to post
Share on other sites

Yout Copyrights are messed up, If you put all rights reserved, thats usually meaning you put some sort of license on it, like the GPL. So far i dont see a copyright FOR the gpl so you can remove that(i put all rights reserved in some of my programs but there now removed) :)

Share this post


Link to post
Share on other sites

Few comments

1. When i type in file name and click search, there are no any sign that tells me it's doing the search, neither like John's which the query box is flashing(at least i know it's searching).

2. The script tend to hang(unable to respond) during the search

3. Copy right thing isn't nesscery because no license was given

Share this post


Link to post
Share on other sites

Few comments

1. When i type in file name and click search, there are no any sign that tells me it's doing the search, neither like John's which the query box is flashing(at least i know it's searching).

2. The script tend to hang(unable to respond) during the search

3. Copy right thing isn't nesscery because no license was given

ok copy right will be removed in next version..

can you tell me how to make it respond while search

Ill make it so you know that its searching...

Share this post


Link to post
Share on other sites

please explane

GUIs run in 2 modes:

- GUIGetMsg mode, and,

- OnEvent mode

The GUIGetMsg mode works by polling the GUI while the OnEvent mode triggers different functions when a particular event occurs (like clicking a button). A GUI can run on only one of the two modes, not both. Search within the AutoIt help file for more (open AutoIt > GUI Reference > OnEvent mode in the help file)

Share this post


Link to post
Share on other sites

GUIs run in 2 modes:

- GUIGetMsg mode, and,

- OnEvent mode

The GUIGetMsg mode works by polling the GUI while the OnEvent mode triggers different functions when a particular event occurs (like clicking a button). A GUI can run on only one of the two modes, not both. Search within the AutoIt help file for more (open AutoIt > GUI Reference > OnEvent mode in the help file)

ahh thanks...

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

*Updated 29th august 2007*

Latest update features:

1) Fully run on html

2) Added set your own transparency.

3) Tells you if it searching

4) Event mode removed

Bugs Fixed

NONE

Edited by ashley

Share this post


Link to post
Share on other sites

tested the program...

1. When I search for something, it says "Searching..." for like close to a minute..

2. The results area then just goes white and doesn't show anything.

That obviously not what you want it to do...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0