Sign in to follow this  
Followers 0
Dethredic

"Spolight" Search possible with autoit?

13 posts in this topic

Hi

I don't know if anyone has seen the "Mac" "Spotlight" search vs the Windows search, but if u have ull notice a big difference.

Spotlight searches as you type, ex. if u type a "A" it will automatically not look at any file without an "A".

The search is much quicker because it is done when u finish typing.

The Windows search takes sevral minutes to complete which is annoying.

Is there anyway i could write a program to make a search like "Spotlight".

I am relitivly new to this program, but would like a challenge, and any help would be appreated, (like where to start, or if it is even possible!)

Thanks


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites



That doesn't sound right ... How does it know the string doesn't have an "A" in it? It still searches every string in that case. It's probably just better written, so the speed is much faster.


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

Share this post


Link to post
Share on other sites

well when my friend searches something he can type "A" then i gets results for everything with an "A" then he can type "P" and it gits rid of everything that came up when he typed "A", without a "P".

Analogy- Itunes, when you search your music libary with the search bar. Like that but for all the files on your computer.


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

well when my friend searches something he can type "A" then i gets results for everything with an "A" then he can type "P" and it gits rid of everything that came up when he typed "A", without a "P".

Analogy- Itunes, when you search your music libary with the search bar. Like that but for all the files on your computer.

Right, as I said, it has to know what does have and what doesn't have so it list them correctly, so it must search every single one... That's what we use StringInStr() for.
If StringInString($sString, 'P') Then;Do something

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

Share this post


Link to post
Share on other sites

Right, as I said, it has to know what does have and what doesn't have so it list them correctly, so it must search every single one... That's what we use StringInStr() for.

If StringInString($sString, 'P') Then;Do something
He means like the index in the helpfile

It reads what you have, and only returns results that so-far fit the entered letters

example:

I have a list with items

abd

add

abb

and I type "ab" in the search, it automatically eliminates "add" since it doesn't fit the description

try Using stringSplit w/o a delimiter so you can compare each letter

Share this post


Link to post
Share on other sites

He means like the index in the helpfile

It reads what you have, and only returns results that so-far fit the entered letters

example:

I have a list with items

abd

add

abb

and I type "ab" in the search, it automatically eliminates "add" since it doesn't fit the description

try Using stringSplit w/o a delimiter so you can compare each letter

You've missed the point as well.... How does it know to eliminate "add"?

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

Share this post


Link to post
Share on other sites

You've missed the point as well.... How does it know to eliminate "add"?

A statement that constantly checks the input, stringsplits it by each letter, and the does the same for each filename, and eliminates the list if they don't start the same

Share this post


Link to post
Share on other sites

A statement that constantly checks the input, stringsplits it by each letter, and the does the same for each filename, and eliminates the list if they don't start the same

Right, which means it has to go through "every" string to determine, if you use string split, you're not getting the entire word, you're only getting the bit after.... I don't see why the concept is so hard to understand really.

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

Share this post


Link to post
Share on other sites

This is the basic concept as I'm understanding it:

$Array = _FindFiles(@HomeDrive, 'compiled')
For $iCC = 1 To UBound($Array, 1) - 1
    MsgBox(64, 'Number of files found = ' & UBound($Array, 1) - 1, _
        'File Name = ' & $Array[$iCC][0] & @CR & 'Location = ' & $Array[$iCC][1])
Next

Func _FindFiles($hDirectory, $sText = '', $iCase = 0)
    Local $aFiles = StringSplit(StringStripCR(_DirRecurse($hDirectory)), @LF)
    Local $aTemp[$aFiles[0] + 1][2], $iAdd, $avArray
    For $iCC = 1 To $aFiles[0]
        $avArray = _PathSplit($aFiles[$iCC])
        If IsArray($avArray) And StringInStr($avArray[3], $sText, $iCase) Then
            $iAdd += 1
            $aTemp[$iAdd][0] = $avArray[3] & $avArray[4]
            $aTemp[$iAdd][1] = $aFiles[$iCC]
        EndIf
    Next
    ReDim $aTemp[$iAdd + 1][2]
    Return $aTemp
EndFunc

Func _DirRecurse($hDirectory)
    RunWait(@Comspec & ' /c dir /b /s /a "' & $hDirectory & '" > "' & _
        @TempDir & '\RecursiveOutput.txt"', @WorkingDir, @SW_HIDE)
    If Not FileExists(@TempDir & '\RecursiveOutput.txt') Then Return SetError(1, 0, 0)
    Local $sFRead = FileRead(@TempDir & '\RecursiveOutput.txt')
    FileDelete(@TempDir & '\RecursiveOutput.txt')
    Return $sFRead
EndFunc

Func _PathSplit($szPath)
    Local $drive, $dir, $fname, $ext, $i, $pos
    Local $array[5]
    $array[0] = $szPath
    If StringMid($szPath, 2, 1) = ":" Then
        $drive = StringLeft($szPath, 2)
        $szPath = StringTrimLeft($szPath, 2)
    ElseIf StringLeft($szPath, 2) = "\\" Then
        $szPath = StringTrimLeft($szPath, 2)
        $pos = StringInStr($szPath, "\")
        If $pos = 0 Then $pos = StringInStr($szPath, "/")
        If $pos = 0 Then
            $drive = "\\" & $szPath
            $szPath = ""
        Else
            $drive = "\\" & StringLeft($szPath, $pos - 1)
            $szPath = StringTrimLeft($szPath, $pos - 1)
        EndIf
    EndIf
    For $i = StringLen($szPath) To 0 Step - 1
        If StringMid($szPath, $i, 1) = "\" Or StringMid($szPath, $i, 1) = "/" Then
            $dir = StringLeft($szPath, $i)
            $fname = StringRight($szPath, StringLen($szPath) - $i)
            ExitLoop
        EndIf
    Next
    If StringLen($dir) = 0 Then $fname = $szPath
    For $i = StringLen($fname) To 0 Step - 1
        If StringMid($fname, $i, 1) = "." Then
            $ext = StringRight($fname, StringLen($fname) - ($i - 1))
            $fname = StringLeft($fname, $i - 1)
            ExitLoop
        EndIf
    Next
    $array[1] = $drive
    $array[2] = $dir
    $array[3] = $fname
    $array[4] = $ext
    Return $array
EndFunc   ;==>_PathSplit


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

Share this post


Link to post
Share on other sites

Smoken- I get your point- it would still have to search every file to determine if it has an "A" in it.

how does spotlight do it so fast then??

maby it only searcheh programs but i dont think so.

p.s.

could you include the ;description in your scripts so i can understand them better (im still learning)


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

Smoken- I get your point- it would still have to search every file to determine if it has an "A" in it.

how does spotlight do it so fast then??

maby it only searcheh programs but i dont think so.

p.s.

could you include the ;description in your scripts so i can understand them better (im still learning)

I suck at commenting, but if you run into a snag, just ask on the forum, others or myself will explain what it's doing.

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

Share this post


Link to post
Share on other sites

ok

well.. i dont really undersand much of it.

and whe ni run it it doesn't do anything.

ill look around but i dont think autoit can make a "spolight search"


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Take a look at RocketLaunch in my sig. It is basically a simple "spotlight" search for the start menu.

Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

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